14 Mart 2015 Cumartesi

Level Boss Random Movements

I'm working on level boss movements for a while. I was stucked with a problem that swaping new position when arrive current position. So, i solve the problem with some help on gamedev web site.

First i need a class which holds the position information.

   public class BossMovement  
   {  
     public Vector2 pos { get; set; }  
     public float speed { get; set; }  
     public float waitTime { get; set; }  
     public BossMovement(Vector2 pPos, float pSpeed, float pWaitTime)  
     {  
       pos = pPos;  
       speed = pSpeed;  
       waitTime = pWaitTime;  
     }  
   }  

And generate positions.

      List<BossMovement> movements = new List<BossMovement>();  
      movements.Add(new BossMovement(new Vector2(300f, 200f), 10f, 4f));        
      movements.Add(new BossMovement(new Vector2(50f, 200f), 7f, 6f));   
      movements.Add(new BossMovement(new Vector2(50f, 400f), 5f, 6f));   
      movements.Add(new BossMovement(new Vector2(300f, 350f), 10f, 6f));   
      movements.Add(new BossMovement(new Vector2(300f, -32f), 10f, 6f));   
      movements.Add(new BossMovement(new Vector2(50f, 32f), 8f, 6f));   

So, i can manage movements.


   public override void Update(GameTime gameTime)  
     {  
       if (!IsNasted)  
       { 
         //Wait for a while
         if (waitTime > 0)  
         { 
 
           waitTime = Math.Max(0.0f, waitTime - Scene.Elapsed);  
           if (waitTime <= 0.0f)  
           {  
             waitTime = 0f;              
           }  
         }  
         else  
         { 
          //Is the sprite arrives the target position?
           if (Vector2.Distance(ConvertUnits.ToDisplayUnits(movements[minx].pos), ConvertUnits.ToDisplayUnits(body.Position)) < 50)  
           {  
             //Change the current position index
             waitTime = movements[minx].waitTime;  
             if (minx == movements.Count - 1)  
               minx = 0;  
             else  
               minx++;  
             //Stop the movement
             body.LinearVelocity = Vector2.Zero;  
           }  
           else  
           {             
             //Move the boss to the specific position 
             Vector2 v = (ConvertUnits.ToDisplayUnits(movements[minx].pos) - ConvertUnits.ToDisplayUnits(body.Position));  
             v.Normalize();  
             body.LinearVelocity = ConvertUnits.ToSimUnits(v * (movements[minx].speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds) );  
           }  
         }  
       }  
       base.Update(gameTime);  
     }  

What are your tips and tricks to successfully finish a hobby game project in your freetime?

What are your tips and tricks to successfully finish a hobby game project in your freetime? How do you motivate yourself to keep it up and drive right through to the finish without losing interest or motivation along the way?
  • Set tiny milestones. Having a goal like "item system works in my RPG game" is all well and good, but that implies a whole lot of under-specified functionality that you probably didn't even know you needed. What about "graphics environment set up"? Or, "A sprite is displayed on the screen."
  • Do a little bit each day. Marathon sessions are great and all, but you're trying to squeeze a long-term commitment into an already crowded life. If you do a little bit each day you are making measurable progress and establishing a structure within which you can achieve your milestones.
  • Scale yourself back. Whatever your grand vision is, try and figure out what the smallest achievable portion is and do that. Making an RPG? Start with one quest and no NPCs. Making a platformer? Start with one level and no enemies.
  • Prototype early. Before you sink a bunch of your hard-earned hobby hours into a game, figure out if it'd be fun first. There's nothing so dispiriting as working your ass off on something for dozens of hours only to find that the basic concept sucks.
  • Develop something iterable. My favorite hobby software projects are the ones where the basic concept allows for later tinkering. Is your game like that? Can you ship something and then revisit it later and add cool stuff?
  • Don't build an engine or a framework. You don't want an engine, you want a game. Don't worry about the framework-y, reusable bits until after your game is shipping. Once you start on the second game, then you can go back to your first and see if there's anything you could bring over. That's not to say that you shouldn't use sound software development praxis, but don't start by writing a Sprite class until you know what you need your sprites to do -- you'd be surprised how little it'll turn out to be. Start with a Hero class, then a Monster class, and then -- oh look! -- there's some common stuff!
  • Shipping is a feature. You're never going to finish your game, you're only going to abandon it. ( = What is the minimum amount you can do before you're not completely embarrassed to show your game to someone else? Chances are, you can do less than that and still have a game to be proud of.