Overhead Exploration Game Problems

Started by MaximusDecimus, Tue 06/03/2012 06:50:42

Previous topic - Next topic

MaximusDecimus

I'm trying to make an overhead game where you explore a place, avoid monsters, unlock doors etc. I'd like to be able to move with the arrow keys only (and not with the mouse). But the built-in code for keyboard movement makes you gently tap the arrow key, then release it and the player moves in a direction. I'd like to press and hold the arrow key and make the character move only when the key is HELD DOWN. Is it possible with AGS?

The second problem is that you're looking at this game from a bird's eye perspective, and there's a big issue with walkable areas. The character is registered at bottom middle, so only that small part of the character cannot pass through walls. I want to achieve that whenever even a single pixel of the character touches a non-walkable area, he stops there. How to do it?

Khris

Look at game_start in GlobalScript.asc, find the line that says
Code: ags
  KeyboardMovement.SetMode(eKeyboardMovement_Tapping);
and change the parameter to eKeyboardMovement_Pressing.

As for the second question: obviously, walkable areas have to be drawn so that they don't touch the walls but leave a border of about half the player's width pixels.
That's the case regardless of whether it's a topdown game or not.

To solve the issue of the pivot being at the bottom center, set the character's .z to a negative number in game_start:
Code: ags
  player.z = -20;

This will move them down (or up) independent of their x/y coordinates. That way you can center the player's sprite on player.x / player.y.

How pixel-perfect the collision is going to be depends on how precisely you draw the walkable areas.
With photoshop and the import walkable area feature you can create the walkable areas for your room quite quickly.

Here's a crude example I did for somebody who had a very wide character, but the principle's the same:

#1 draw area on entire floor area                            #2 move 1 copy to the left, one to the right, one up, one down

# actual area is intersection of all parts

Construed

Awe Khris, your so sweet, Always spending your hard earned time helping us newbs.
5 million thumbs up to you my good man  ;)
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

SMF spam blocked by CleanTalk