Note that there are some explanatory texts on larger screens.

plurals
  1. POI'm making a game, can/should I create an "Enemy" class?
    primarykey
    data
    text
    <p>I'm making a game for my final project in an XNA class I'm taking, it's going to be a FPS. In order to generate enemies, I figured that I could write a class that imports a model and defines the random size and placement of the "Enemy", as well as his movements and actions. I would then call that class from my Game.cs file. However, I'm having some difficulty with this.</p> <p>My main issue is that I'm not sure where/how to call the Enemy (which is a snowman) in the Game file. </p> <p>Here's what I have for the Snowmen.cs (enemy) class</p> <pre><code>public class Snowmen : Microsoft.Xna.Framework.Game { private Camera cam = new Camera(); Model snowMan; Matrix[] snowManMatrix; protected override void LoadContent() { snowMan = Content.Load&lt;Model&gt;( "Models\\snowman" ); snowManMatrix = new Matrix[ snowMan.Bones.Count ]; snowMan.CopyAbsoluteBoneTransformsTo( snowManMatrix ); } public void DrawSnowMan(Model model, GameTime gameTime) { foreach (ModelMesh mesh in model.Meshes) { Matrix world, scale, translation; scale = Matrix.CreateScale(0.02f, 0.02f, 0.02f); translation = Matrix.CreateScale(0.0f, 0.7f, -4.0f); world = scale * translation; foreach (BasicEffect effect in mesh.Effects) { effect.World = snowManMatrix[mesh.ParentBone.Index] * world; effect.View = cam.viewMatrix; effect.Projection = cam.projectionMatrix; effect.EnableDefaultLighting(); } mesh.Draw(); } } protected override void Draw(GameTime gameTime) { DrawSnowMan( snowMan, gameTime ); base.Draw(gameTime); } } </code></pre> <p>As of right now, My <em>Game1.cs</em> file is a functional skybox and also contains <code>LoadContent()</code> and <code>Draw()</code> methods. Is the enemy class completely unnecessary?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload