public TCM_DrawingObject(TCM_Graphics g, Color fillColor, Color outlineColor, float lineWidth) : base(g) { this.fillColor = fillColor; this.outlineColor = outlineColor; this.lineWidth = lineWidth; shape = graphics.createGeometry(Shape.rectangle, 0, 0, 1, 1); }
public static void runLoop() { startUp(); RenderLoop.Run(TCM_Graphics.form, step); TCM_Audio.clear(); TCM_Graphics.dispose(); TCM_Audio.disposeAudio(); }
public TCM_GraphicsObject(TCM_Graphics g) { transform = new RawMatrix3x2(1, 0, 0, 1, 0, 0); frontChildren = new List <TCM_GraphicsObject>(); backChildren = new List <TCM_GraphicsObject>(); parent = null; graphics = g; }
public TCM_BitmapObject(TCM_Graphics g, string filename) : base(g) { setBitmap(filename); transparency = 1; x = 0; y = 0; w = 1; h = 1; }
public Enemy() { facingLeft = (id % 2 == 0); gravity = 2; maxFallSpeed = 60; maxSpeed = 5; int height = 120; int width = 80; setMainBox(width, height, Anchor.center); addVisual(new BitmapVisual(TCM_Graphics.loadPNG("robot"), -width / 2, -height / 2, width, height)); setTransform(1, 0, 0, 1, 600, 400); }
public static void step() { TCM_Audio.cleanOutSources(); TCM_Graphics.beginDraw(); control.storeInputs(); bool playing = true; if (playing) { if (getButton(ButtonEnum.rb) == ButtonState.down || getButton(ButtonEnum.rb) == ButtonState.pressed) { control.vib.RightMotorSpeed = (ushort)(getAnalog(AnalogEnum.rt) * 65535); control.setVibration(control.vib); } if (getButton(ButtonEnum.lb) == ButtonState.down || getButton(ButtonEnum.lb) == ButtonState.pressed) { control.vib.LeftMotorSpeed = (ushort)(getAnalog(AnalogEnum.lt) * 65535); control.setVibration(control.vib); } if (getButton(ButtonEnum.start) == ButtonState.pressed) { paused = !paused; /*if (paused) * TCM_Audio.pauseAllAudio(); * else * TCM_Audio.resumeAllAudio();*/ } if (!paused) { //put game code here currentRoom.step(); frameCount++; } else { //put menu code here currentRoom.draw(); pause.draw(); if (getButton(ButtonEnum.back) == ButtonState.pressed) { TCM_Graphics.form.Close(); } } } control.storeGamepad(); TCM_Graphics.endDraw(); Thread.Sleep(20); }
private static void startUp() { frameCount = 0; TCM_Graphics.Initialize("Game", 1920, 1080, new Color(0, 0, 0, 1)); TCM_Audio.Initialize(); rooms = new List <Room>(); rooms.Add(new Room(2, 1, true)); currentRoom = rooms[0]; currentRoom.initialize(); pause = new Frame(); //working on it, does scrolly text, needs to be able to reset //ProgressingTextVisual pauseText = new ProgressingTextVisual("PAUSED - back to quit\ntesting how much text i can fit in this box" // + "\napparently that wasn't enough, so i'll just keep adding until something weird starts happening", new Color(1, 1, 1, 1)); //pauseText.setBoundingBox(490, 280, 940, 520); //pauseText.setFormat("Consolas", 32); //List<ProgressingTextVisual> scrolly = new List<ProgressingTextVisual>(); //scrolly.Add(pauseText); TextVisual pauseText = new TextVisual("PAUSED - back to quit\ntesting how much text i can fit in this box" + "\napparently that wasn't enough, so i'll just keep adding until something weird starts happening", new Color(1, 1, 1, 1)); pauseText.setBoundingBox(490, 280, 940, 520); pauseText.setFormat(pauseText.format.FontFamilyName, 32); pauseText.setFormat("Consolas", 32); BitmapVisual pauseBitmap = new BitmapVisual(TCM_Graphics.loadPNG("blank"), 480, 270, 960, 540); pauseBitmap.setTransparency(.5f); pause.addVisual(pauseBitmap); pause.addVisual(pauseText); if (new Controller() != null) { control = new TCM_Controller(new Controller(UserIndex.One)); control.LSDeadZone = .18; control.RSDeadZone = .18; control.axialLeft = false; control.axialRight = false; } else { } }
public Player() : base() { currentAction = PlayerAction.idle; gravity = 2; maxSpeed = 20; jumpStrength = 30; maxFallSpeed = 60; actionFrame = 0; jumpFrame = 0; grounded = false; int height = 200; int width = 100; idealLocation = new RawVector2(TCM_Graphics.form.ClientSize.Width / 2, TCM_Graphics.form.ClientSize.Height / 2); setMainBox(100, 200, Anchor.center); addVisual(new BitmapVisual(TCM_Graphics.loadPNG("bird"), -width / 2, -height / 2, width, height)); setTransform(1, 0, 0, 1, 1920 / 2, 1080 / 2); }
public void draw() { //apply transform TCM_Graphics.applyTransform(transform); //draw stuff behind for (int i = 0; i < backChildren.Count; i++) { backChildren[i].draw(); } //draw this innerDraw(); //draw stuff in front for (int i = 0; i < frontChildren.Count; i++) { frontChildren[i].draw(); } //undo transform TCM_Graphics.revertTransform(); }
public override void innerDraw() { TCM_Graphics.drawTextVisual(this); }
public void setBitmap(string filename) { bitmap = TCM_Graphics.loadBitmapFromFile(filename); }
public GameObject(TCM_Graphics g) { display = new TCM_DrawingObject(g, new SharpDX.Mathematics.Interop.RawColor4(1, 1, 1, 1), new SharpDX.Mathematics.Interop.RawColor4(.5f, .5f, .5f, 1), 2); ((TCM_DrawingObject)display).setGeometry(TCM_DrawingObject.Shape.rectangle, -60, -60, 120, 120); }
public TCM_LayerObject(TCM_Graphics g) : base(g) { x = 0; y = 0; }
public TCM_TextObject(TCM_Graphics g, string text, Color color) : base(g) { this.text = text; setFormat("Arial", 18); this.color = color; }
public void initialize() { farBackground = new Frame(); midground = new Frame(); closeBackground = new Frame(); platformLayer = new Frame(); actorLayer = new Frame(); playerLayer = new Frame(); closeForeground = new Frame(); farForeground = new Frame(); addChild(farBackground, true); addChild(midground, false); midground.addChild(closeBackground, true); midground.addChild(platformLayer, false); midground.addChild(actorLayer, false); midground.addChild(playerLayer, false); midground.addChild(closeForeground, false); playerLayer.addChild(player, false); actorLayer.addChild(new Enemy(), false); addChild(farForeground, false); BitmapVisual backgroundBitmap = new BitmapVisual(TCM_Graphics.loadPNG("wall1")); backgroundBitmap.opacity = .5f; backgroundBitmap.setBoundingBox(0, 0, 1920 + (width - 1) * 16 * 60, 1080 + (height - 1) * 9 * 60); farBackground.addVisual(backgroundBitmap); int squaresWide = 16 * width + 1; int squaresTall = 9 * height + 1; string wallImage = "wall1"; if (enclosed) { //makes the 4 walls Platform topPlatform = new Platform(); topPlatform.applyTransform(TCM_Matrix3x2.translate(-60, -60)); topPlatform.setMainBox(120 + 1920 * width, 120, Anchor.topLeft); platforms.Add(topPlatform); Platform bottomPlatform = new Platform(); bottomPlatform.applyTransform(TCM_Matrix3x2.translate(-60, -60 + 120 * (squaresTall - 1))); bottomPlatform.setMainBox(120 + 1920 * width, 120, Anchor.topLeft); platforms.Add(bottomPlatform); for (int i = 0; i < squaresWide; i++) { topPlatform.addVisual(new BitmapVisual(TCM_Graphics.loadPNG(wallImage))); topPlatform.visuals[i].boundingBox = new SharpDX.Mathematics.Interop.RawRectangleF(i * 120, 0, 120 * (i + 1), 120); bottomPlatform.addVisual(new BitmapVisual(TCM_Graphics.loadPNG(wallImage))); bottomPlatform.visuals[i].boundingBox = new SharpDX.Mathematics.Interop.RawRectangleF(i * 120, 0, 120 * (i + 1), 120); } Platform leftPlatform = new Platform(); leftPlatform.applyTransform(TCM_Matrix3x2.translate(-60, 60)); leftPlatform.setMainBox(120, 120 + height * 1080, Anchor.topLeft); platforms.Add(leftPlatform); Platform rightPlatform = new Platform(); rightPlatform.applyTransform(TCM_Matrix3x2.translate(-60 + 120 * (squaresWide - 1), 60)); rightPlatform.setMainBox(120, 120 + height * 1080, Anchor.topLeft); platforms.Add(rightPlatform); for (int i = 0; i < squaresTall - 2; i++) { leftPlatform.addVisual(new BitmapVisual(TCM_Graphics.loadPNG(wallImage))); leftPlatform.visuals[i].boundingBox = new SharpDX.Mathematics.Interop.RawRectangleF(0, 120 * i, 120, 120 * (i + 1)); rightPlatform.addVisual(new BitmapVisual(TCM_Graphics.loadPNG(wallImage))); rightPlatform.visuals[i].boundingBox = new SharpDX.Mathematics.Interop.RawRectangleF(0, 120 * i, 120, 120 * (i + 1)); } } else { for (int i = 0; i < squaresWide; i++) { Frame bottomPlatform = new Frame(); bottomPlatform.applyTransform(TCM_Matrix3x2.translate(-60 + 120 * i, -60 + 120 * (squaresTall - 1))); bottomPlatform.addVisual(new BitmapVisual(TCM_Graphics.loadPNG(wallImage))); bottomPlatform.visuals[0].boundingBox = new SharpDX.Mathematics.Interop.RawRectangleF(0, 0, 120, 120); platformLayer.addChild(bottomPlatform, false); } } //makes the floating platform Platform middlePlatform = new Platform(false, false, true, false); middlePlatform.applyTransform(TCM_Matrix3x2.translate(360, 540)); middlePlatform.setMainBox(120, 15, Anchor.topLeft); middlePlatform.addVisual(new BitmapVisual(TCM_Graphics.loadPNG(wallImage))); middlePlatform.visuals[0].boundingBox = new SharpDX.Mathematics.Interop.RawRectangleF(0, 0, 120, 15); platforms.Add(middlePlatform); //puts the platforms into a layer foreach (Platform p in platforms) { platformLayer.addChild(p, false); } }