VaW progress: Week 3

Published August 31, 2011
Advertisement
Hi again!

So, what have I been up to this week? Well, I was a little bit busy with other things not related to programming, and I also spent a day creating a C wrapper and corresponding Pascal DLL loader for my game library, which I mentioned a couple weeks ago as something I should do.

So it's time for a screenshot, yet again:
week3.png

You'll notice there's another veggie on the scene! I started doing a little bit of AI work. I created a Ruby AI class for different types of AI to be derived from, which only has two base methods to be overwritten: 'init' and 'run'. Init is obviously run when the AI is created and run is called every frame. It also stores the ID of the Player instance (which I mentioned last week) that it is controlling. My intention for this minimalistic base is so that I can implement any sort of AI system I feel like, because there aren't any hard and fast rules implemented. As I experiment the base AI class might expand though.

For a laugh, I decided to quickly implement the AI of the original VaW; enemies mindlessly walk toward you, aiming to your exact coordinate and firing as fast their weapon could shoot:


class TestAi < Ai
def run
# Find the target asset, which is the asset the player is controlling, and the asset this AI is controlling
target = $assets[$players[0].focus]
me = $assets[$players[@player_id].focus]
# Break if either are nil
return nil if (target == nil) || (me == nil)

# Move towards the target, in the same fashion as the original VaW: slowing down the closer it got
right((target.x-me.x)/50.0)

# Aim towards the enemy with deadly accuracy
aim(direction_to_asset(me.instance_id, target.instance_id))

# Fire as fast you can!
trigger
end
end

Simple. Although I surely don't intend to keep the AI like this forever tongue.gif

It's also fun to switch round and play with the tomato, having the AI control the carrot!

Next up was sorting out velocity on Character assets. Before, when the player pressed left and right, they would instantly travel in that direction. The assets had an X and Y velocity beforehand, but for the horizontal plane it may as well have not been there. You could also change your direction in mid air in any way you pleased. This was a problem for a feature which I'll mention in a minute. I changed the code from this (in pseudo code):

if left pressed {
x velocity = -speed
} else if right pressed {
x velocity = speed
} else x velocity = 0

to

if left pressed {
x velocity += (difference between destination velocity (-speed) and current velocity) * (interpolation value)
} else if right pressed {
x velocity += (difference between destination velocity (speed) and current velocity) * (interpolation value)
} else x velocity -= (current velocity) * (interpolation value)


This interpolation value changes depending on whether the player is in the air or not, with a lower value if they're in the air. Now the player smoothly starts and stops moving when on the ground pretty quickly, but when in the air it's harder to change direction, which I prefer. I've also made it so that you can control the distance of your jump with the jump button. For longer jumps hold it down for longer, and for small jumps, just a quick press is needed. This is also done by changing the interpolation value. To make sure that this still happens even when left and right are pressed, the left pressed/right pressed branches just do a goto to the final else branch if the player is in the air.

The final thing I want to mention (which I'm still tweaking), is the Force class I've added (well, it's a struct on the C++ side). Forces can either be Explosions, Implosions, or Beams. Explosions and Implosions obviously push outwards and inwards, respectively, in a circle. Beams are rectangles of pushing force, like a fan blowing (or a Star Wars Force Push smile.gif). Forces keep acting on objects until they are destroyed. I was able to implement rocket jumping by simply creating an Explosion force when a bullet was destroyed! It wasn't perfect though as the force needed to be destroyed a few frames after it's creation. I'll probably make an explosion asset, to deal with this, which would manage the creation and destruction of the force with a particle effect thrown in.

So that's all for this week! Again, I won't have a great deal of time to work on the game this coming week as I'll be in France until Sunday, and then I'll be starting school the day after.

See you next time!

Max
@supermaximo93
Previous Entry VaW progress: Week 2
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement