Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbLoopObject question

Author
Message
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 31st Jul 2007 08:04 Edited at: 31st Jul 2007 08:10
I got this motorcycle i want to ride across the wasteland, so i set it up with animations for the wheels turning, turning right, turning left and hopping on the backwheel. I assigned to each its own control arrow key and the space bar for the one-wheel stunt.

When i ride i usually and instinctively keep pushed the UpKey while at the same time push the LeftKey or RightKey when i want to turn and release it only if i want to push the DownKey if i want to go backwards. Also when i want to do the stunt animation i do it while the UpKey is pressed.

My problem is that when i push any key while keeping down the UpKey, the animation switches to the last keyframe immediately without playing it. I would like the animations to play at least once and then hold the last frame until i resume pushing only the UpKey...

So... my question is: How do i do all that stuff that i just said i wanna do?

I included for your convenience the entire project so you can play it and take a look... OH!! One thing before i forget: the project is set to work at 1600x1200, you may want to change that before running it!

Thanks in advance!
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 31st Jul 2007 08:13
umm... for some reason, i don't know why i try to upload the rar file with my project but i keep on finding this "automatic_file"... so i don't know... the file should be a 15Mb rar file.

Anyway here is the code, there is no texture or X file provided thou:

Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 31st Jul 2007 17:57 Edited at: 31st Jul 2007 17:58
Quote: "So... my question is: How do i do all that stuff that i just said i wanna do?
"


i've lost faith in dbLoopObject... it never seemed to work with me...

instead, i use a variable to keep track of the frame count


and, in the mainloop, i use this lil diddy to keep the object animation looping (placed somewhere in the mainloop)...


here's the start and stop anim functions...


and here's what i do when i want to stop and restart the animations...


i hope this helps... you should be able to figure out the relevant parts, as originally, this is from some of my OOP code which is set up for class methods and calls...

good luck

--Mike
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 5th Aug 2007 22:08
umm, gotta admit i'm still confused:



i did a bare minimum of improvisation but i don't quite understand how to adapt your suggestions to my code, and if i compile it it gives a few errors like:

Quote: "1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(79) : error C2063: 'StartAnim' : not a function
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(79) : error C2601: 'Dwarf::StartAnim' : local function definitions are illegal
1> e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(54): this line contains a '{' which has not yet been matched
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(82) : fatal error C1903: unable to recover from previous error(s); stopping compilation"


Where am i supposed to go from here?
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 5th Aug 2007 22:48
StartAnim and Stop Anim are methods of the Dwarf class... you wouldn't call those, seeing as you are not using classes...

look at the code in Dwarf::StartAnim, and Dwarf::StopAnim...

simply write that lil bit of code into two separate functions called StartAnim() and StopAnim()... putting the appropriate object number in the code...

then call em in place DwarF::xxx...

in short, you are keeping the frame count and using it to start and stop the anim... and, to keep it going...

ok... change this...


to this...


--Mike
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 6th Aug 2007 00:36
mmh... me begins to think me needs more grey matter... urgh...



Any way to make it simpler...?
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 6th Aug 2007 12:54
almost there fabio...

first, i'd put the variable declaration for frameCount outside the loop...

second... change StartAnim() to look like this...

this restarts the anim at the last frameCount...

finally...

add this so that the top of your mainloop looks like this...

this constantly retrieves the frameCount, keeps the object animation looping by resetting it if frameCount equals total frames, and in case you press the stop anim key the frameCount is always ready for when you restart the anim...

--Mike
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 7th Aug 2007 06:24
lol this is one of those emabrrassing moments when i feel i should have taken C++ classes

If i run the modiified code below i get the following errors:

Quote: "1>------ Build started: Project: SHELTER, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(58) : error C2065: 'objID' : undeclared identifier
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(62) : error C3861: 'StartAnim': identifier not found
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(70) : error C3861: 'StartAnim': identifier not found
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(92) : error C3861: 'StartAnim': identifier not found
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(96) : error C2373: 'StartAnim' : redefinition; different type modifiers
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(96) : error C2601: 'StartAnim' : local function definitions are illegal
1> e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(56): this line contains a '{' which has not yet been matched
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(103) : error C2601: 'StopAnim' : local function definitions are illegal
1> e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(56): this line contains a '{' which has not yet been matched
1>e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(117) : fatal error C1075: end of file found before the left brace '{' at 'e:\all projects\project shelter\8 game code\shelter\shelter\main.cpp(4)' was matched
1>Build log was saved at "file://e:\ALL PROJECTS\PROJECT SHELTER\8 GAME CODE\SHELTER\SHELTER\Debug\BuildLog.htm"
1>SHELTER - 8 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="


What did i do now?

i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 7th Aug 2007 06:45
Mike, i have uploaded the entire project with source files and everything here, so you can have a clearer view of what i have done:

http://fabiobasile.com/SHELTER.rar
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 7th Aug 2007 13:02
Have a little push ahead, check the attachment.

Attachments

Login to view attachments
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 7th Aug 2007 16:14
Quote: "Have a little push ahead, check the attachment. "


It's a lot clearer now, thanks!

So at this point, if i use something like:



how do i control which frames of the animation are to be played?

for example the animation of the character is split in 5 phases:

walk 0/60
run 61/110
stand 111/111
take 112/134
pick up 134/200
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 7th Aug 2007 16:56
well here is what i tried, but i'm not sure if my guess was anywhere near to what i should have done...

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 20th Sep 2007 20:00
Did you get the motorcycle animations working?

Login to post a reply

Server time is: 2024-09-29 03:27:27
Your offset time is: 2024-09-29 03:27:27