public void render(Camera camera, SpriteBatch spriteBatch) { Vector2 drawDimen = new Vector2(rect.Width, rect.Height) * camera.scaleAt(layer - 2); Vector2 drawTL = camera.toScreen(new Vector2(rect.X, rect.Y), layer - 2); spriteBatch.Draw(Textures.get("pixel"), Util.tl(drawTL, drawDimen), Color.Lerp(new Color(1F, 0F, 0F, 0.5F), Tile.baseLayerColors[layer], 0.5F)); }
public Player(Vector2 pos) : base(pos, -1) { texture = Textures.get("Player"); dimen = Util.dimen(texture); hasStep = false; }
public static void loadMapData(string levelName) { mapData = new int[3][, ]; for (int k = 0; k < 3; k++) { mapData[k] = loadColorMap(Textures.get(levelName + "MapData" + k), Tile.genTileTable()); } }
public DeathWall(float xPos, float zPos) : base(new Vector2(xPos, ChunkMap.mapHeight() / 2F), zPos) { vel = Vector2.UnitX * 10; hasGravity = false; hasCollision = false; crusher = Textures.get("DeathWallCrusher"); armSegment = Textures.get("DeathWallArm"); crusherDimen = Util.dimen(crusher); armDimen = Util.dimen(armSegment); dimen = new Vector2(armDimen.X, ChunkMap.mapHeight()); }
public void deathReset() { dead = false; pos = Runner.playerStartPos(); zPos = -1; vel = Vector2.Zero; texture = Textures.get("Player"); rotation = 0; rotSpeed = 0; gravityDir = 1; }
public override void renderUnder(Game game, SpriteBatch spriteBatch) { float scale = 15; Texture2D body = Textures.get("EyeBody"); Texture2D eyeOut = Textures.get("EyeOuter"); Texture2D eyeIn = Textures.get("EyeCenter"); Vector2 center = new Vector2(1920, 1080) / 2; spriteBatch.Draw(body, Util.center(center, Util.textureVec(body) * scale), Color.White); Vector2 off = centerMouseOff / 20; off = Util.setMag(off, Math.Min(50, Util.mag(off))); Vector2 eyePos = center + off; spriteBatch.Draw(eyeOut, Util.center(eyePos, Util.textureVec(eyeOut) * scale), Color.White); spriteBatch.Draw(eyeIn, Util.center(eyePos + off / 2, Util.textureVec(eyeIn) * scale), Color.White); }
private static Texture2D genBackAtlas(string identifier) { string blockIdentifier = identifier.Substring(0, identifier.IndexOf("Back")); Texture2D texture = Textures.get(blockIdentifier); var arr = Util.colorArray(texture); var newArr = new Color[arr.Length]; for (int i = 0; i < arr.Length; i++) { Color col = arr[i]; newArr[i] = Color.Lerp(arr[i], new Color(Color.Black, col.A / 255F), 0.3F); } var back = new Texture2D(Runner.getGraphicsDeviceManager(), texture.Width, texture.Height); back.SetData(newArr); return(back); }
public void render(Camera camera, SpriteBatch spriteBatch) { Vector2 fromVec = from.ToVector2(); Vector2 toVec = to.ToVector2(); Vector2 diff = toVec - fromVec; int count = (int)Util.mag(diff); diff = Vector2.Normalize(diff); int layer = WiringEditor.editLayer; Vector2 drawDimen = Vector2.One * camera.scaleAt(layer - 2); for (int i = 0; i < count; i++) { Vector2 drawTL = camera.toScreen(fromVec + diff * i, layer - 2); spriteBatch.Draw(Textures.get("pixel"), Util.tl(drawTL, drawDimen), Color.Lerp(new Color(0F, 0F, 1F, 0.5F), Tile.baseLayerColors[layer], 0.5F)); } }
public void die() { if (dead) { return; } deathTime = 1; dead = true; if (switchTime > 0) { zPos = Util.lessDiff(zPos, switchTo, switchFrom); // TODO: make this look better (only not noticeable since switch is so fast) switchTime = -1; } puffDeath(); SoundPlayer.play("Explosion", 0.6F); texture = Textures.get("invis"); Runner.shakeScreen(0.4F, 0.6F); }
public static void genAtlas() { var types = Util.GetValues <type>(); fullAtlas = new Texture2D(Runner.getGraphicsDeviceManager(), 48, 48 * (types.Count() - 1)); var colorArr = new Color[fullAtlas.Width * fullAtlas.Height]; int i = 0; foreach (var tile in types) { if (tile == type.Air) { continue; } string identifier = tile.ToString(); Texture2D atlas = (!Textures.has(identifier) && identifier.Contains("Back")) ? genBackAtlas(identifier) : Textures.get(identifier); var atlasCol = Util.colorArray(atlas); for (int x = 0; x < atlas.Width; x++) { for (int y = 0; y < atlas.Height; y++) { int index = x + y * atlas.Width; int fullIndex = x + (y + atlas.Height * i) * atlas.Width; colorArr[fullIndex] = atlasCol[index]; } } i++; } fullAtlas.SetData(colorArr); }
public override void update(float deltaTime) { hasCollision = !godMode; hasGravity = !godMode; float rotMult = (grounded) ? 1 : 0.5F; float toRotSpeed = (vel.X / 20) * Maths.twoPI * rotMult; float rotAccelMult = (grounded) ? 10 : 3F; rotSpeed += (toRotSpeed - rotSpeed) * deltaTime * rotAccelMult; rotation += rotSpeed * deltaTime; deathTime -= deltaTime; if (dead && deathTime <= 0) { Runner.failLevel(); } if (dead) { return; } base.update(deltaTime); collideInsides(); collideTouching(); if (pos.Y > ChunkMap.mapHeight() - 10) { vel = -Vector2.UnitY * 20; die(); } if (pos.Y < 10) { vel = Vector2.UnitY * 20; die(); } if (!dead) { animationTimer -= deltaTime; const float blinkStart = 0.4F; if (animationTimer > 0 && animationTimer < blinkStart) { int index = (int)((blinkStart - animationTimer) / blinkStart * 5); if (index > 2) { index = Math.Max(0, 5 - index); } texture = Textures.get("Blink" + index); } else { texture = Textures.get("Player"); if (animationTimer < 0) { animationTimer = Util.random(3, 10); } } } switchTime -= deltaTime; if (switchTime > 0) { float toZ = Util.revSinLerp(switchTime, switchTimeStart, switchFrom, switchTo); if (!tryMoveToZ(toZ)) { startSwitchTo(switchFrom); SoundPlayer.play("Bonk", 0.5F); } } checkOclusion(); }