Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
namespace ProjektName { class Enemy { public Sprite EnemySprite; public Vector2 gunOffset = new Vector2(25, 25); private Queue<Vector2> waypoints = new Queue<Vector2>(); . . .was auch immer public Enemy( Texture2D texture, Vector2 location, Rectangle initialFrame, int frameCount) { EnemySprite = new Sprite(location, texture, initialFrame, Vector2.Zero); for (int x = 1; x < frameCount; x++) { inhalt } } public void AddWaypoint(Vector2 waypoint) { waypoints.Enqueue(waypoint); } public bool WaypointReached() { inhalt } public bool IsActive() { inhalt } public void Update(GameTime gameTime) { inhalt } public void Draw(SpriteBatch spriteBatch) { if (IsActive()) { EnemySprite.Draw(spriteBatch); } } } } |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Shooter { public class eater : Enemy { public eater(); // Animation representing the enemy public Animation EnemyAnimation; // The position of the enemy ship relative to the top left corner of thescreen public Vector2 Position; // The state of the Enemy Ship public bool Active; // The hit points of the enemy, if this goes to zero the enemy dies public int Health; // The amount of damage the enemy inflicts on the player ship public int Damage; // The amount of score the enemy will give to the player public int Value; // Get the width of the enemy ship public int Width { get { return EnemyAnimation.FrameWidth; } } // Get the height of the enemy ship public int Height { get { return EnemyAnimation.FrameHeight; } } // The speed at which the enemy moves float enemyMoveSpeed; public void Initialize(Animation animation, Vector2 position) { } public void Update(GameTime gameTime) { // The enemy always moves to the left so decrement it's xposition Position.X -= enemyMoveSpeed; // Update the position of the Animation EnemyAnimation.Position = Position; // Update Animation EnemyAnimation.Update(gameTime); // If the enemy is past the screen or its health reaches 0 then deactivateit if (Position.X < -Width || Health <= 0) { // By setting the Active flag to false, the game will remove this objet fromthe // active game list Active = false; } } public void Draw(SpriteBatch spriteBatch) { // Draw the animation EnemyAnimation.Draw(spriteBatch); } } } |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
private void AddEater() { // Create the animation object Animation EATERAnimation = new Animation(); // Initialize the animation with the correct animation information EATERAnimation.Initialize(EATERTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true); // Randomly generate the position of the enemy Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + EATERTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100)); // Create an enemy eater EATER = new eater(); // Initialize the enemy EATER.Initialize(EATERAnimation, position); // Add the enemy to the active enemies list EATER.Add(EATER); |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »potu1304« (27.08.2011, 21:27)
C#-Quelltext |
|
1 2 3 |
rectangle2 = new Rectangle((int)eaters[j].Position.X - eaters[j].Width / 2, (int)eaters[j].Position.Y - eaters[j].Height / 2, eaters[j].Width, eaters[j].Height); |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »potu1304« (29.08.2011, 14:13)
Werbeanzeige