Home | Register new account | Login | Search for a message | Currently Online
Poster
Ryan
Subject: 2 Quick Suggestions
(Posted on 06/26/05 - 10:48:48 PM)
Member

szrrya@yahoo.com
Ryan's website

Turn smilies off

First, I'd recommend storing the input in another variable just so you can check it later if need be. Not sure if anyone else does this, but I always do something like:

a$ = UCASE$(INKEY$)

That way if I'm checking for a keypress, in my if checks or select cases I only need like a CASE "A". That's beside the point of your question, though...

In reference to your problem, I recommend doing something to totally change the way you decide when to move the enemy. I believe the best way you'll find is to use the TIMER statement. This will make it standard for all computers that play the game. So... add some code like this:

In your DIM statements:
DIM enmove!

Notice this isn't an integer, but a single precision variable so we can keep track of times less than a second. Next, add this code before the DO...LOOP:

enmove! = TIMER

This will set the variable to the current TIMER setting. In your loop, instead of incrementing the enemystep% and checking it against enwait%, use the following IF check:

IF TIMER - enmove! >= 1 THEN
...
(Enemy movement code)
...
enmove! = TIMER
END IF

Notice what this does. First it checks to see if the current TIMER value is at least a second greater than what we stored in enmove!. If it is, it moves the enemy and then resets the enmove! variable to the current TIMER setting. TIMER reads in seconds, so every second the enemies will now move. You can increase or decrease that value to make your enemies move more or less. Also, you could create several different variables to keep track of events and have them all work at different times. Maybe you'd want tiles to animate every .5 seconds, or some slow monsters to move only every 5 seconds. It's up to you!

Let me know if you have any more questions.

Replies to this message:
There are no replies to this message.


Post a reply:
Nickname: You are not logged in. If you have a registered account you should login before posting.
Subject:
Message: