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 / Moving Sprite with Dark GDK 2.0

Author
Message
Shyft
7
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 26th May 2012 08:27
I have seriously tried to figure this out before posting so I hope the answer isn't too obvious. I used DBPro for awhile but have learned C++ and now want to leverage the power of OOP so I thought Dark GDK would be the perfect option since I am familiar with the functions of DBPro.

Anyway to get to my issue. In DBPro I used the Paste Sprite command to relocate sprite, I quickly noticed this command did not work the same in GDK and my assumption is that it simply pastes the sprites image but the original sprite is still in the same position is was before the paste command. So I started searching the forums and it seemed the solution was to use dbSprite(), but the problem is that I cannot find that command in GDK 2.0. Has it been removed? If so how do I move a sprite based on its x and y coords now? I do not need to use the move command that takes a float for velocity, I want to put the sprite is specific spots.

Thanks for the help

Mistrel
Retired Moderator
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 26th May 2012 20:05
I'm not sure how you plan on pasting a sprite if you haven't created one yet. The command you are looking for has been renamed for clarity to dbCreateSprite.

Don't forget to have a look at the fantastic documentation provided with DarkGDK 2.0. You should find everything you need to help get you started there.

If some commands are behaving strangely for you, check to make sure that their parameters haven't changed. Many commands have been updated.

Shyft
7
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 26th May 2012 20:24 Edited at: 26th May 2012 20:46
I wasn't completely clear sorry about that, I have already created the sprite and want to move it using x and y parameters after it has been created.

Mistrel
Retired Moderator
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 26th May 2012 23:43
It could be many different possibilities. It's hard to guess without seeing some example code.

Did you remember to use dbSync() at the end of your loop?

Shyft
7
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 27th May 2012 04:35
Yes dbSync() was at the bottom of my loop.

Is dbPasteSprite supposed to move the sprite to the coords passed in? The way the documentation read I couldn't be sure. I saved the x and y positions of the sprite after the create sprite command and paste sprite command were called and the spriteX,spriteY still returned the original sprite x and y from creation but there was now two images of the sprite on screen.

I guess my question is: What command would I use to change the x and y positions of a sprite by passing those values as parameters, after creation?

MadBit
Valued Member
10
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 28th May 2012 10:34
have a go dbCLS() at the beginning of your loop.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Jun 2012 20:07
I agree that the "renaming for clarity" is rather the other way around.
It seems that the only wrapper for the original sprite function is dbCreateSprite (just set the ID parameter (to that of a pre-existing Sprite) to move it). Because of this, the same function will also be used to change the sprite's image.

It might be worthwhile to create two more wrapper functions, say "dbSetSpritePosition" and "dbSetSpriteImage" if naming clarity is what is sought after
(Something you can easily do by yourself if you're keen about it by the way).


"Why do programmers get Halloween and Christmas mixed up?"
Shyft
7
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 5th Jun 2012 23:53
Thanks for the help, I see how it works now. It does seem a bit confusing the Create sprite would also move a pre-existing sprite though.

Mistrel
Retired Moderator
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 6th Jun 2012 02:14
It used to be called "dbSprite()" which I thought was a bit confusing because it didn't say you were creating it.

Isn't movement what dbPasteSprite is for?

Shyft
7
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 6th Jun 2012 02:27
Yeah thats what I originally though, but after testing all it did was render the same image as the sprite at the new coords. The original sprite stayed where it was and SpriteX, SpriteY returned its original coords after the pastesprite function was called.

Mistrel
Retired Moderator
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 6th Jun 2012 02:33
I don't like having these two commands merged into one as it's an exception to convention. There is already a dbMoveSprite command so I'll have to think about how to address this.

Shyft
7
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 6th Jun 2012 02:46
perhaps you could overload dbMoveSprite to take either x,y or velocity?

Marsh0
10
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 6th Jun 2012 07:55 Edited at: 6th Jun 2012 08:05
Quote: "
Isn't movement what dbPasteSprite is for?"


...

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size

Login to post a reply

Server time is: 2019-08-22 05:44:45
Your offset time is: 2019-08-22 05:44:45