In this example, you can see fence, plants, roads, walls, etc. Notice it's not a true top-down, but still works. |
Add some walls (or other impassable objects) to your world and then begin the process of setting up the code to not allow actors to pass through them.
For example, in your "move" section, you could do something like this:
- If you press the "up" key, move up 5
- If you're now touching the object you can't pass through, move down 5
If you're moving your character 1 block at a time, you can also do:
- If you can see the wall, don't move -- OR... if you can NOT see the wall, move.
Imagine now that you have other classes -- mud, quicksand, brush, etc. Maybe if you're in mud, your movespeed is slowed by 1 -- or if you're in quicksand, your move speed is super slow. Maybe brush is impassable -- but if you hit it with your sword X times, it breaks and goes away.
I'll do my best to demo wall code during class.
In this example, you can see the sprite edges. |
Right now we're in a "locked" world with a specific dimension. But as we learn more code, we'll see how it's possible to have a much larger world with a scrolling exploration mode. The example below shows a ridiculously large world, but it's definitely a potentially cool game.
No comments:
Post a Comment