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.

Newcomers DBPro Corner / little help here

Author
Message
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 1st Jan 2009 16:03 Edited at: 1st Jan 2009 16:04
Hi a'am a beginner in darkbasic pro and I need a little help on how to animate the character,,cuz when I write the loop object command it doesn't work so here is my code

sync on
sync rate 60

backdrop on
color backdrop 0


hide mouse



make matrix 1,1000,1000,10,10
position matrix 1,0,0,0



rem Load player
player=1
load image "media/ninja/1.jpg",1
load object "media/ninja/ninja.md2",player
yrotate object player,180
texture object player,1
set object speed player,30
playerframe#=total object frames(player)/200.0

do

if move=1 then loop object player,0*playerframe,9*playerframe



x#=object position x(player)
y#=object position y(player)
z#=object position z(player)
a#=object angle x(player)
d#=10.0
h#=10.0
s#=50.0


move=0
set camera to follow x#,y#,z#,a#,d#,h#,s#,1

if rightkey () = 1 then yrotate object player,wrapvalue (object angle y(player)+3) : move=1
if leftkey () = 1 then yrotate object player,wrapvalue (object angle y(player)-3) : move=1
if upkey () = 1 then move object player,-1 : move=1
if downkey () = 1 then move object player,1 : move=1


sync
loop
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 2nd Jan 2009 02:10
I think the problem is the way you are working out the frame numbers when u are using loop object.


What is this line supposed to do?



I see you used the exact same line for the other model in your previous post. I doubt both models use the same animation frames.

Now, It doesn't help, that when you define the variable playerframe# you declare it as a float. But the next two references



you've missed off its "#", DBPro thinks this playerframe integer is a new variable, (with a value of 0), so 0*0 will be 0, and 9*0 is 0.

This is a huge reason why u'r struggling with this I think.

I am at a loss tho, as to what the playerframe# variable is actually for. and why you are using it in the loop object command. It would be easier if you used actual values e.g.



Hope thats helped a little

Please use code tags And please, reply here rather than starting off a new thread. I almost missed this one coz it has a fairly nondescript Title.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Guyra
19
Years of Service
User Offline
Joined: 10th Nov 2005
Location: Norway
Posted: 2nd Jan 2009 04:32 Edited at: 2nd Jan 2009 04:36
Basically the same problem as in this thread: Link

Try changing this:


To this:



the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 2nd Jan 2009 13:44
okee thanks guys but can you help me with the fucntions, i wanna use the functions but it just gives me a message...
can you just tell me how to use function s
thanks.. :d
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 2nd Jan 2009 13:49
my last wish is how to make gravity pleaase this is my last problem..
i want to make the player jump when the space key is pressed
Lord Einstein
19
Years of Service
User Offline
Joined: 22nd Oct 2005
Location: Well here, of course...
Posted: 2nd Jan 2009 13:56
Instead of looping the object every loop try to instead set the interpol. It won't make a difference graphicly but it might increase speed.

As for gravity just have a value called "grav#" or something and increase it by 0.16 every loop and move the player down by that value. You then set grav# to 0 when the player collides with the floor. If the player is pressing the spacekey and is colliding with the floor just set the grav# value to a minus number e.g. -2. The lower the number the higher the jump. This creates quite a nice jumping a gravity effect perfect for simple games.
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 2nd Jan 2009 14:22 Edited at: 2nd Jan 2009 14:24
hehe thanks for the reply but can you explain it a little easier,,
you could write a code and it would be veryy nice of you
I wrote this

py#=object position y(player)
gy# =object position y(ground)

grav# = 0.16
move object down player,grav#


if py# => gy# then grav# = 0

if spacekey () = 1 and grav#=0 then grav# = 0.10

thanks
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Jan 2009 04:47
Have you searched with the search box under every screen in the forums? I mean - this question is asked all the time... I mean ALL the time... There has got to be 100's of homemade "gravity" examples in these pages... I thnk people would be slow to take time out of there day to write yet another one - but if they want to - cool.. but I'd search a bit more man.

--Jason

the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 3rd Jan 2009 21:18
thanks for tou reply but brother I canät find the right thread.. please can you explain to how it works

thankss
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Jan 2009 23:18


Try that

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Jan 2009 04:10
Hey - when I made that code snip it worked great - I went to run it again a bit ago and it was all messed... I'm investigating

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Jan 2009 04:46
Here it is again - but sadly - this is with the timer not being used to adjust the animation speed - but I'm at a loss why it worked b4 and not now - the FPS I'm getting is 1300+ and I wonder



Pressing "1" pushes the block back up... anyways... I tried - I'm tired - brain done for the day

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Jan 2009 05:16
sorry for triple post - just dawned on me why this is acting screwy one version to next - first first is RIGHT EXCEPT... I get FPS 1300+ but the timer function is milliseconds...

I think I have to add code where is FPS > 1000 I used FPS as my timer thingy or SOMEthing.. then if its under or equal 1000 use the timer.

There is a performance timer doo dad that I think has higher resolution but I've read its flawed based on cpu cycles - and definately turns into a thicker topic then simple gravity - ugh... always something.

--Jason

the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 4th Jan 2009 17:32 Edited at: 4th Jan 2009 17:32
thanks you but pleaase just give me a code like grav#=0 jump#=1
so
and explain pleaase:d
sorry for my questions
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Jan 2009 20:10
Hmm... Well - That was a huge effort to just out of the blue whip out a gravity sample, with timer movement, a physics heart beat system.. and a box that actually bounces with commented code at that...

I think I'll leave this to someone else more capable of helping you... You'll find that simple one liners aren't going to give you decent anything...

--Jason

Login to post a reply

Server time is: 2024-11-24 15:11:17
Your offset time is: 2024-11-24 15:11:17