I dont know how the hell to make a character move with a series of animations.
I want it to run 3 or 4 pictures in a row when i push a key, seperated by about a half a second. I also want it to rerun the series for as long as the key is pushed. I know how to loop it but I want it to stop when I release the key.
I know this is dumb but, hey, Im new at this stuff
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
You could use the getkeystate API, use it like this.
VB Code:
If GetKeyState(vbKeyLeft) < 0 Then MsgBox "The Left arrow key is pressed"
To achieve what you want, you could perhaps, put it in your loop and have it exit the loop (exit do/while) if it's >0 (i.e. not pressed).
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
Sorry, forgot the declaration.
VB Code:
Public Declare Function GetKeyState Lib "user32" Alias "GetKeyState" (ByVal nVirtKey As Long) As Integer
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
Look into the gettickcount api, there are lots of examples in this forum.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
It works, yes, but a loop is more accurate and you can better manage the timing. By the way: VB has pre-defined constants for all those ROPs like vbSrcCopy or vbSrcPaint.
Originally posted by Yhoko It works, yes, but a loop is more accurate and you can better manage the timing. By the way: VB has pre-defined constants for all those ROPs like vbSrcCopy or vbSrcPaint.
Yhoko
Someone other then me has pointed the constant thing out, finally =).
Yes, when writing games, Timers are simply one of the worst things that you can use. They are inaccurate, inflexible, and a pain in the arse to do anything moderatly complex with. For reference, here is a standard game loop:
Code:
While running
CheckInput()
Update()
Render()
DoEvents
Wend
You can expand the above to limit frame rates:
Code:
Const Delay As Long = 25
Dim lt as Long
lt = GetTickCount()
While running
If lt + Delay > GetTickCount()
CheckInput()
Update()
Render()
lt = GetTickCount()
End If
DoEvents
Wend
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
[worthless post]
Code:
'Slow down the FPS...
Do Until GetTickCount() >= LastTick + TicksPerFrame
DoEvents
Loop
DebugMsg "Frame delay: " & GetTickCount() - LastTick - TicksPerFrame 'Show the delay
LastTick = GetTickCount()
This is the code I always use... This way you don't have to encapsulate everything in that IF, in my first game I had so many nested blocks in the main loop that I couldn't have my comments bigger than 30 characters (or I would have to manually word-wrap them and that's very annoying when you're concentrating on the coding). Hmm... ok... so it's not a very good excuse. Wait, it shows the frame delay When the game is ok it varies from 0 to 5 every frame. If it's slow it will of course go up. DebugMsg just shows a line of text on the screen. It's a good reference because when you're limiting the FPS you usually don't measure it
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."