public Game() { window = new RenderWindow(new VideoMode(800, 600), "LoL"); window.Closed += (object sender, EventArgs e) => { (sender as Window).Close(); }; window.SetFramerateLimit(200); gTime = new GameTime(); }
public void Update(GameTime gTime) { lifetime -= gTime.Ellapsed.Milliseconds; spr.Position += dir * speed * gTime.Ellapsed.Milliseconds / 120; //Pixel wird bewegt if (lifetime < 0) isAlive = false; }
public void Update(GameTime gTime) { lifetime -= gTime.Ellapsed.Milliseconds; if (lifetime < 0) isAlive = false; spr.Position += dir * gTime.Ellapsed.Milliseconds * speed / 200; }
public override void Update(GameTime gTime) { animation(gTime); if (special.Ticks == 0) activate(); else deactivate(gTime); }
public override void Update(GameTime gTime) { animation(gTime); if (a) activate(); //Checkt die Collision mit dem Player. else deactivate(gTime); //Testet ob die Aktion(Verlangsamung...) abgelaufen ist. }
private void deactivate(GameTime gTime) { special = special.Subtract(new TimeSpan(gTime.Ellapsed.Ticks)); if (special.Ticks < 2) { special = new TimeSpan(0); Map01.player.baseMovementSpeed *= 2; } }
private void deactivate(GameTime gTime) { special = special.Subtract(new TimeSpan(gTime.Ellapsed.Ticks)); //Console.WriteLine(special.Seconds); if (special.Ticks < 2) { special = new TimeSpan(0); Map01.player.sterblich = true; } }
private void deactivate(GameTime gTime) { special = special.Subtract(new TimeSpan(gTime.Ellapsed.Ticks)); //Console.WriteLine(special.Seconds); if (special.Ticks < 2) { special = new TimeSpan(0); Map01.player.baseMovementSpeed /= 2; } }
public void animation(GameTime gTime) { time += gTime.Ellapsed; if (time.Milliseconds >= 100) { time = new TimeSpan(0); if (sprite.TextureRect.Left > 12) sprite.TextureRect = new IntRect(12, 0, 30, 64); else sprite.TextureRect = new IntRect(62, 0, 30, 64); //sprite.Origin = new Vector2f(sprite.TextureRect.Width / 2, sprite.TextureRect.Height / 2); } }
public void animation(GameTime gTime) { time += gTime.Ellapsed; if (time.Milliseconds >= 400) { time = new TimeSpan(0); if (sprite.TextureRect.Left > 50) sprite.TextureRect = new IntRect( 7, 0, 66, 70); else sprite.TextureRect = new IntRect(74, 0, 66, 70); sprite.Origin = new Vector2f(sprite.TextureRect.Width / 2, sprite.TextureRect.Height / 2); } }
public void animation(GameTime gTime) { time += gTime.Ellapsed; if (time.Milliseconds >= 100) { time = new TimeSpan(0); if (sprite.TextureRect.Left > 150) sprite.TextureRect = new IntRect(0, 0, 56, 39); else if (sprite.TextureRect.Left < 5) sprite.TextureRect = new IntRect(56, 0, 56, 39); else if (sprite.TextureRect.Left < 60) sprite.TextureRect = new IntRect(121, 0, 56, 39); else sprite.TextureRect = new IntRect(187, 0, 56, 39); sprite.Origin = new Vector2f(sprite.TextureRect.Width / 2, sprite.TextureRect.Height / 2); } }
public void Update(GameTime gTime) { foreach(Speed t in speed) { if(t.a || t.special.Ticks != 0) //Entweder wenn Objekt speed aktiviert oder wenn der TImer noch aktiv ist t.Update(gTime); } foreach(Unsterblich q in invincable) { if (q.a || q.special.Ticks != 0) q.Update(gTime); } foreach(Burger t in burger) { if (t.a || t.special.Ticks != 0) t.Update(gTime); } foreach(Doublejump t in doublejump) { if (t.a || t.special.Ticks != 0) t.Update(gTime); } }
void Sprung(GameTime gTime) { //TODO: Optimieren mit gTime if (jump) { //GravitationAbsolut = baseGravitationAbsolut; //GravitationAbsolut = -1f; maxheight = sprite.Position.Y - jumpingHeight; //Console.WriteLine(maxheight); GravitationAbsolut = maxheight/300 ; Console.WriteLine(maxheight); jump = false; isJumping = true; --jumptrue; } }
private void deactivate(GameTime gTime) { special = special.Subtract(new TimeSpan(gTime.Ellapsed.Ticks)); if (special.Ticks < 2) //"Knapp daneben" Zitat Matthis; Hö ? { a = true; special = new TimeSpan(0); //Map1.player.baseMovementSpeed *= -1; MovementSpeed = 0.6f; Map01.player.bewegungumdrehen *= -1; sprite.Color = col; //Farbe wird zurückgesetzt. } }
//TODO: Löschen wenn nicht mehr gebraucht /* public void (GameTime gTime) { time += gTime.Ellapsed; if (time.Milliseconds >= 100) { time = new TimeSpan(0); if (sprite.TextureRect.Left > 150) sprite.TextureRect = new IntRect(0, 0, 56, 39); else if (sprite.TextureRect.Left < 5) sprite.TextureRect = new IntRect(56, 0, 56, 39); else if (sprite.TextureRect.Left < 60) sprite.TextureRect = new IntRect(121, 0, 56, 39); else sprite.TextureRect = new IntRect(187, 0, 56, 39); sprite.Origin = new Vector2f(sprite.TextureRect.Width / 2, sprite.TextureRect.Height / 2); } } */ public override void Update(GameTime gTime) { //animation(gTime); if (a) activate(); //Checkt die Collision mit dem Player. }
public void Update(GameTime gTime) { //Alle Gegner Objekt Klassen kriegen update. foreach (Geist t in geister) { t.Update(gTime); } foreach (Zombie t in zombies) { t.Update(gTime); } }
public override void Update(GameTime gTime) { MovementSpeed = baseMovementSpeed * gTime.Ellapsed.Milliseconds; if (aktion == 0) verfolgen(); if (aktion == 1) bewegung(); animation(gTime); if (a) activate(); else deactivate(gTime); }
public EGameState Update(GameTime gTime) { if (Keyboard.IsKeyPressed(Keyboard.Key.Escape)) return EGameState.TitleScreen; gTime.Update(); if (gTime.Total.Seconds >= start.Seconds - 1 || gTime.Total.Minutes > 0) //StartCountdown { player.Update(gTime); } else { } if (player.a) { player.animation(gTime); } else { player.deadanim(gTime); } enemy.Update(gTime); powerups.Update(gTime); pH.Update(gTime); return EGameState.Map1; }
public abstract void Update(GameTime gTime);
public EGameState Update(GameTime t) { throw new NotImplementedException(); }
public void animation(GameTime gTime) { int[] x = null, y = null, w = null, h = null; int i = 0, animtime = 0; time += gTime.Ellapsed; //TODO: Abfrage für Animation laden/starten wenn im Ziel bzw. am Start //TODO: Animation vervollständigen //TODO: Abfrage, wenn Player beschleunigt!? //TODO: Abhängig von Sprung machen(bzw. Gravitation 0 & Richtungstaste abfangen) //TODO: Funktion für isMovingRight schreiben und das umdrehen durch den Geist beachten if (GravitationAbsolut != 0) { if (isMovingright) { sprite.Texture = textjumprechts; if (auswahl == "Tofu") { x = new int[] { 4, 52, 104, 153 }; //X-Koordinaten von denen ausgeschnitten werden y = new int[] { 0, 0, 0, 0 }; //Y-Koordinaten von denen ausgeschnitten werden soll w = new int[] { 48, 48, 48, 48 }; //Länge der Bilder h = new int[] { 78, 78, 78, 78 }; //Höher der Bilder animtime = 300; //Dauer der Animation animrepeat = true; //Ob die Animation wiederholt werden soll } if (auswahl == "Cookie") { x = new int[] { 0, 59, 117, 176 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 56, 56, 56, 56 }; h = new int[] { 58, 58, 58, 58 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie2") { x = new int[] { 0, 41, 80 }; y = new int[] { 0, 0, 0 }; w = new int[] { 41, 39, 74 }; h = new int[] { 61, 61, 61 }; animtime = 300; animrepeat = true; } } else { if (isMovingleft) { sprite.Texture = textjumplinks; if (auswahl == "Tofu") { x = new int[] { 4, 52, 104, 153 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 48, 48, 48, 48 }; h = new int[] { 78, 78, 78, 78 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie") { x = new int[] { 0, 54, 114, 171 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 54, 60, 54, 60 }; h = new int[] { 58, 58, 58, 58 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie2") { x = new int[] { 111, 72, 0 }; y = new int[] { 0, 0, 0 }; w = new int[] { 41, 39, 72 }; h = new int[] { 61, 61, 61 }; animtime = 300; animrepeat = true; } } else // isIdle { sprite.Texture = textidle; if (auswahl == "Tofu") { x = new int[] { 4, 52, 104, 153 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 48, 48, 48, 48 }; h = new int[] { 78, 78, 78, 78 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie") { x = new int[] { 0, 54, 114, 171 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 54, 60, 54, 60 }; h = new int[] { 58, 58, 58, 58 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie2") { x = new int[] { 0, 0, 0 }; y = new int[] { 0, 0, 0 }; w = new int[] { 72, 72, 72 }; h = new int[] { 61, 61, 61 }; animtime = 300; animrepeat = true; } } } } else { if (isMovingright) { sprite.Texture = textlaufenrechts; if (auswahl == "Tofu") { x = new int[] { 4, 52, 104, 153 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 48, 48, 48, 48 }; h = new int[] { 78, 78, 78, 78 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie") { x = new int[] { 0, 59, 117, 176 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 56, 56, 56, 56 }; h = new int[] { 58, 58, 58, 58 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie2") { x = new int[] { 1, 44, 87 }; y = new int[] { 0, 0, 0 }; w = new int[] { 45, 45, 43 }; h = new int[] { 64, 64, 64 }; animtime = 100; animrepeat = true; } } else if (isMovingleft) { sprite.Texture = textlaufenlinks; if (auswahl == "Tofu") { x = new int[] { 4, 52, 104, 153 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 48, 48, 48, 48 }; h = new int[] { 78, 78, 78, 78 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie") { x = new int[] { 0, 54, 114, 171 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 54, 60, 54, 60}; h = new int[] { 58, 58, 58, 58 }; animtime = 300; animrepeat = true; } if (auswahl == "Cookie2") { x = new int[] { 2, 44, 88 }; y = new int[] { 0, 0, 0 }; w = new int[] { 44, 44, 42 }; h = new int[] { 64, 64, 64 }; animtime = 100; animrepeat = true; } } else { sprite.Texture = textidle; if (auswahl == "Tofu") { x = new int[] { 4, 52, 104, 153 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 48, 48, 48, 48 }; h = new int[] { 78, 78, 78, 78 }; animtime = 300; animrepeat = true; } else if (auswahl == "Cookie") { x = new int[] { 0, 59, 117, 176 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 56, 56, 56, 56 }; h = new int[] { 58, 58, 58, 58 }; animtime = 300; animrepeat = true; } else if (auswahl == "Cookie2") { x = new int[] { 0, 67, 133, 199 }; y = new int[] { 0, 0, 0, 0 }; w = new int[] { 67, 67, 67, 67 }; h = new int[] { 64, 61, 64, 64 }; animtime = 500; animrepeat = true; } } } if (checkneueanim(sprite.TextureRect,x,y,w,h)) sprite.TextureRect = new IntRect(x[0], y[0], w[0], h[0]); else if (time.Milliseconds >= animtime) { time = new TimeSpan(0); while (sprite.TextureRect.Left != x[i]) { ++i; } if (i == x.Length - 1 && animrepeat) { i = 0; sprite.TextureRect = new IntRect(x[i], y[i], w[i], h[i]); } else { if(i != x.Length - 1) ++i; sprite.TextureRect = new IntRect(x[i], y[i], w[i], h[i]); } } // Console.Write("Animationtime: " + time.Milliseconds + "; \t"); sprite.Origin = new Vector2f(sprite.TextureRect.Width / 2, sprite.TextureRect.Height / 2); }
public void deadanim(GameTime gtime) { if (deadtime.TotalMilliseconds > 1700) sprite.TextureRect = new IntRect(0, 0, 68, 64); else if (deadtime.TotalMilliseconds > 1400) sprite.TextureRect = new IntRect(68, 0, 68, 64); else if (deadtime.TotalMilliseconds > 1100) sprite.TextureRect = new IntRect(132, 0, 68, 64); else sprite.TextureRect = new IntRect(202, 0, 68, 64); }
void KeyboardInput(GameTime gTime) { //TODO: Beschleunigung!? isMoving = true; if (Keyboard.IsKeyPressed(Keyboard.Key.Up)) Sprung(gTime); else if (jumptrue == 1) jump = true; if (Keyboard.IsKeyPressed(Keyboard.Key.Left)) { MovingDirection = new Vector2f(-10, 0); isMovingright = false; isMovingleft = true; } else if (Keyboard.IsKeyPressed(Keyboard.Key.Right)) { MovingDirection = new Vector2f(10, 0); isMovingright = true; isMovingleft = false; } else { MovingDirection = new Vector2f(0, 0); isMoving = false; isMovingleft = false; isMovingright = false; } MovingDirection *= bewegungumdrehen; if(!Map01.map.IsWalkable(this)) { MovingDirection = new Vector2f(0, 0); } Vector2f check = MovingDirection * -1; if(!(MovingDirection.Equals(new Vector2f(0,0)) || check.Equals(new Vector2f(0,0))) && GravitationAbsolut == 0) //Partikel werden nur erstellt wenn er den Boden berührt { Vector2f start = new Vector2f(sprite.Position.X,sprite.Position.Y + 15); Map01.pH.SpawnMoveParticles(500, 30, gTime, start, MovingDirection, 2); } }
public override void Update(GameTime gTime) { Map01.hud.Update(score); Map01.hud.Update(Position); if (deadtime.Seconds < 0) { if(a == false) { sprite.Position = startpos; maxheight = sprite.Position.Y; a = true; sterblich = true; } GravitationSpeed = baseGravitationSpeed * gTime.Ellapsed.Milliseconds; MovementSpeed = baseMovementSpeed * gTime.Ellapsed.Milliseconds; KeyboardInput(gTime); if (Map01.map.IsWalkable(this)) Move(); Gravitation(gTime); } else { deadtime = deadtime.Subtract(new TimeSpan(gTime.Ellapsed.Ticks)); } }
public void Gravitation(GameTime gTime) { //if(GravitationAbsolut <= 10f) // GravitationAbsolut += GravitationSpeed; MovementSpeed = GravitationAbsolut; float div = sprite.Position.Y - maxheight; div = (div + 1) / 30; if (div >= 10f) div = 10f; if (GravitationAbsolut == 0) ++GravitationAbsolut; //Console.WriteLine(GravitationAbsolut); //Console.WriteLine(collmap()); //Console.WriteLine("Position - maxheight: " + Math.Abs(div) + "\t Collision: " + collmap()); if (isJumping) { korrektur = 2; sprite.Position -= new Vector2f(0, div) * gTime.Ellapsed.Milliseconds / 5; } else if(!isJumping && collmap()) { sprite.Position += new Vector2f(0, div) * gTime.Ellapsed.Milliseconds / 5; } else { MovingDirection = new Vector2f(0, 0); jump = true; jumptrue = basejumptrue; GravitationAbsolut = 0f; maxheight = sprite.Position.Y - 50; isJumping = false; } MovingDirection = new Vector2f(0, div) * gTime.Ellapsed.Milliseconds / 5; if (Math.Abs(div) < 1f) isJumping = false; }