Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[XP] Storing steps of an event in a variable.

Hey Ho.

I was puzzled about the way I should make my system.
The situation is this:

http://img183.imageshack.us/img183/5486/somerandomscreeney8.png[/img]

The '25' on the right is the amount of steps you are allowed.
The purpose of the level is to hit the highlighted square.
(within the allowed step ratio)

That lousy character is an event, which moves just like the player would.
(the player is somewhere there too, but I've got my reasons for not just using that)
Press up, and it goes up, press down, it goes down, etc.
Now this may not be the perfect example, but hey.

I would like to request a (and I assume it would be rather small) script which stores the amount of steps taken by that event (or some other random event) in a (or multiple other) variable(s).
 
Ok, this was already a little to 'sophisticated' and a little too simple at the same time.
I just wanted to add '1' to a variable whenever a specific event moved.
(because in some levels there'll be three moving events)

However, since I just wanted the script to add '1' I tried what you said, but modified the script call to:

Code:
loop do
  if Input.repeat?(Input::UP ||       
  Input::DOWN || Input::LEFT || 
  Input:: RIGHT)
    $game_variables[003] += 1
   break
  end
end

I get a 'script is hanging' error though.
 
But what if you can't make a move? (IE you're stuck in a corner, or against a wall)
Then you press right, you don't move, but still you 'did a step'..

Think about it.

If it could be done with events, I'd have done it.
There's no way for an event to check whether or not you have moved.
(except for storing x and y values, and checking them,  but that's not flawless either)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top