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 / Animation help

Author
Message
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 21st Jun 2007 17:19
I am currently working on a game called Dungeongame. I've been working on this for quite a while now, and I have run into yet another problem. Animation. The player is supposed to attack when you just click the Left mouse button, but the problem is that you have to hold the left mouse button.Here is the code.


I just put the entire code there in case the problem is being caused by something else than what i excpect.
Sorry if this has been asked alot before...Thanks
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 21st Jun 2007 22:44
Ah, and the model I used was the knight model that came with DarkMatter 1, in which i believe came with DarkBasic. Sorry if it caused any confusion.
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jun 2007 01:02
OHH...the true is out there !! can`t you feel the force?...

hallo Existence I,v got a example ready, but I don`t know if you want the player attack holding all time the mouse button ...my model just play one animation at a time just with a click


have a look to my code



oh my god

Attachments

Login to view attachments
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 22nd Jun 2007 10:10
That's a good example, but I've already tried that. It was the one that got me started with animations It works fine but it doen't work if you hold the button down unless you take out the 'SET OBJECT FRAME objectnum,framenum' part. So I took that part out of the movement code, but then if I tried putting that code back in the attack code, the animation doen't even play...even if you don't hold the click. But if I take out that code again from the attack code, I must hold down the mousclick. That's my problem. But thanks anyway for the example. *Off Topic*Oh yeah and If somehow you got the example to work, by importing the Knight model from DarkMatter, you have to turn the camera around to the back and you will see him there. Still a work in progress.
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 24th Jun 2007 20:52
Does anyone want to help? I would really appreciate it...?
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Jun 2007 04:40
I would but I'm having trouble here as well. I do know that Each model can have a series of "animation" frames. And I'm pretty sure you can have groups of them that perform a "animation sequence" and can loop sections of it or whatever.

Not looking at your code however, and from your original problem description - its possible your problem goes deeper than animation.

In your main loop - things are happening rather fast, and what you might need is a way to use that mouse button DOWN to cause an event - and event that can not be fired off again UNTIL the first event is finished.

This event could simple be a variable that measures time since animation started. When the "pretty much correct" amount of time goes by that your animation normally takes - reset the variable to ZERO. when this variable is ZERO - then you can look for that mouse button click again.

There is a thread in here somewhere title "keystate monitor" that might have something of interest in it for you - it has optional time delays for keypresses so for example if spacebar=fire weapon =- you could control how fast it can shoot. The same principle applied to your animation sequence MIGHT be the real trick you need.

I'm just trying to help.
Jason

Know way to many languages - Master of none
ThinkDigital
19
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 25th Jun 2007 10:04 Edited at: 25th Jun 2007 10:05
Change this


to this



I think that's what you need. It follows what Jason said - you can't loop the object over again if it's already looping between frames 25 and 49.

"Variables won't, constants aren't."
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 25th Jun 2007 16:58
This is quite interesting...I see the logic in what Jason said, and in your code, ThinkDigital. Yet I still have them same problem, but I'm guessing that I must setup a timing part in my program and probably have something like it must play for as long that timer is going...or somthing like that
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Jun 2007 22:59
I wish you luck with it. If you get thie jist of what we are suggesting - you will probably figure this out one way or the other.

I really think you should look at that keystate monitor code here:

http://forum.thegamecreators.com/?m=forum_view&t=107531&b=6

It has timer code to prevent keypresses from repeating to quickly like I mentioned before. I'd thought I'd show you the link is all.

Keep us posted how you make out. It could help anyone of us who get into an animation bind.

Know way to many languages - Master of none
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 27th Jun 2007 13:05 Edited at: 27th Jun 2007 13:12
I'm still having absolutly no luck at all on this and I am actually quite frustrated. I have tried using a timer system and It works but you STILL have to hold down the mouseclick. It is not repeating that is my trouble. It is that you have to hold down the click...

I'll tinker with it some more but I don't really think I'll have any luck. Any help would be appreciated.


Sorrry if I'm a slow learner...
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Jun 2007 13:47
Is this all standard media that comes with DBPro? Without knowing I'm not going to try to get this working - in short - bundle the media and upload it so I/we can snag it.

Note: GameWorld filename is misspelled "gamewrold" or something.

Actually - looking at your code - you don't seem like a slow learner. You just aren't familiar with software design is all and that takes time to learn for everyone. Anyone can toss a program together that does something - but making the program organized so that you can make it grow - takes organization and writing code to be able handle your tasks one step at a time - so as each loop iterates through - you can advance everything appropriately a TINY Bit... then more each loop.

This takes a creative approach and experimentation. What you are asking for is not that hard to add to what you have - but I got to go to work - so I got to get in the shower and go so I'm not late but - if you upload the media I'll try to get to it tonight.. I'll probably give ya a half hour tops - but that should be enough - get the media uploaded on here so I can download your code and media - toss it in a directory - and begin.

Thanks
Jason

Know way to many languages - Master of none
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 27th Jun 2007 13:57 Edited at: 27th Jun 2007 14:25
Yeah I know that it says 'gamewrold'. I mispelled it when I made the file and was too lazy to fix it. I'm the knight model came out of DarkMatter 1 and it DID come with DBPro so I guess I can post it in a dowload thing...

The dowload thing is hard...
I don't know if this will work because I've never used the download thing before but...
Here you go...

*sigh* I have forgotten to put the gameworld in so just make a plain and turn up the ambient light and unhide the ambient light


Here is the (New) code:

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Jun 2007 16:53 Edited at: 27th Jun 2007 16:58
Well Wait - Careful. I just want to make sure I have everything. Do not post DBPro included stuff - I'll have that.

Just make sure I have the gameworld file and anything else not part of DBPro. I just want to be able to see what you see quickly - and then attack the code with a solution that helps you out with the actual problem and maybe teaches a principle you can apply to other things for this platform (meaning DBPro programming).

There are multiple ways to skin this cat in other languages - but I'll stay focused on the task at hand here.

The MAIN priniciple (I'll know better when I have your code working on my system) is kind of like the old school phrase "Time Sharing" - except we are using a SINGLE thread - so we need to emulate that. The code I'll write will demonstrate it to some degree or another I'm sure - but this is important to learn in principle more than anything because any cool things that happen in your game need to usually be worked in like this.

Got to go for now. Get any media I'll need in here online (Except the DBPro stocking stuffers )

[edit]
Well, I see you did now - I didn't notice the download icon. I already had the knight - I have DarkMAtter 1. I Think I want #2 though - more space stuff and vehicles etc.

Ok. I just don't have Gameworld.
I'll revisit this tonight.

Know way to many languages - Master of none
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 28th Jun 2007 01:23
Oh ok I was gone all day . The gameworld isn't very good and to see you will have to first turn up the ambient light and unhide the ambient light, and I also have control camera using arrowkeys on for devlopment to see how to fix the lighting and stuff. To see the Charactar, you must turn the camera around to the back room(yes I do notice the crack between the two rooms...maybe coloring the backdrop black will hide it...). You should be good from there.

Now here's the gameworld(dungeongame gamewrold.x)
As you can see it's done in 3DWS and It's not very good because, um, I modelled it...

And I don't have collision in yet.

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Jun 2007 04:53 Edited at: 7th Aug 2007 23:32
Ahhh --- Ok - I took some major liberties in structuring your code for a few reasons.

1: Readability - though your code wasn't ugly - just a little cryptic due to hardcoded object id's

2: Gosub Crazy. Gosub is not really the "way to go" - typiccally functions are better - however dbpro has a few quirks on how you have to init types and (I think also ) constants outside of a function. so Gosub is good for making that happen without needing all that init stuff at the very top of your file.

3: Utilized some code I wrote for polling input - some of it borrowed from here some not - makes reading the code concerning input easier - not more KEYSTATE(30) - Now: KeyState(cnScanCode_A)

4: Separated user input form actions. Not the way I do it - but almost. This is a little simpler to read than what I do. This should make some sense though when you see the logic for how to move the guy - the code doesn't read "if this key then rotate" ... it reads more like "grPlayer.bGoLeft = keystate(cnScanCode_W)"
then in the "PlayerActions" it takes all the keypresses into account to decide how to carry on.

5: Made MOST of your hardcoded numbers dynamic - for object player anyway - I gave you code that allows you to get "ID numbers" the same way for all "things" in DBPro - like objects, terrain, matrix, images etc.


Well - here is the code. I think you will be quite pleased.

BTW - This wasn't a half hour of work - more like 3-4
Went from 156 lines of code to 671 There are quite a few spacer lines - but you'll see. I also tried to comment liberally for your sake - learning from etc.




Best Regards Bro - Have Fun
Jason p "Sage"

Know way too many languages - Master of none
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 28th Jun 2007 11:51
I think I'm going to cry...I didn't know anyone would be as kind to tottaly rewrite my program into a way that works all the while teaching me how should really code... Your my Hero, Man.

Thank you, Jason.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 28th Jun 2007 12:47
this post is inspiring

Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 29th Jun 2007 07:28
Haha yeah

Anarchy Burger - hold the Government!

Login to post a reply

Server time is: 2024-11-25 15:36:13
Your offset time is: 2024-11-25 15:36:13