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.

DarkBASIC Professional Discussion / Paste Sprite command help

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Jan 2013 00:28
Not quite sure how this command should work. I have some code from Hands On DBP vol 1 It is supposed to randomize, load an image, set up a sprite then randomly paste the sprite around the screen 10 times with 1 second wait in between pastes.

Is it supposed to paste it and leave it there? All I see is a couple of flashes of the sprite here and there on the screen and not 10. This code is copied directly from the book.

Thanks in advance and HAPPY NEW YEAR!!!!
Dragonslayer
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Jan 2013 01:01
Are you talking about pages 498-499?

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Jan 2013 01:25
yes!
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Jan 2013 03:02
There is no SYNC being called, and also no control over sync rate, alternatively I could be wrong, But after implementing sync control... I got it to move around every 1000ms...

I am relatively new to 2D so, hope this helps somewhat... you could alternatively place the sprite in an off screen coordinate such as -100,-200 instead of that written in the document...

And then use the placement command to randomly paste it elsewhere on the board...



Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Jan 2013 22:54
I will play around with it. I posted this yesterday and don't even remember if it was DBP or DarkGDK! I have been flipping back and forth doing the stuff in the book in DBP and then switching to DarkGDK and doing it there. I have run into some of these problems in GDK and those are already set up with sync.

I am pretty new to 2D also and have done very, very little in 3D. I am still trying to learn the core language first and at the same time trying to learn c++. I kind of decided to drop the c++ and learn DBP and GDK at the same time and as I get better and kind of have the basics of both languages down dig deeper into c++ and use GDK as the main tool I use. There is not much to use to learn GDK, the few tuts are nothing so I figured learning DBP and porting the exercises in the book to GDK would be good. Learn the best of both worlds at the same time.

I ported one of the DarkGDK tuts, the game level tut to DBP and ran it and did not see any speed difference. I just think C++ may be better mainly because you can use classes. I don't know a lot about those yet but what I do know I like very much!!!
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Jan 2013 23:56
Well I tried the sync commands everywhere in the code and with a sync command anyplace in the code all I get is a black screen. This is in DBP.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Jan 2013 00:26
Quote: "I just think C++ may be better mainly because you can use classes."


As time progresses you will feel the difference. However, for some small games, DBP would suffice without the need for classes; but learning C++ at the same time with DGDK is still a good investment. Being able to inherit from other classes saves time and effort.

Paste Sprite

There should really be a main loop with a single call to the sync command at the end of the loop. Sync should be switched on. Here is the minimum requirement for paste sprite to have any use:



As far as I know, in DGDK, sync is always on or on by default? Correct me if I am wrong.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 3rd Jan 2013 01:27
I'll try this! Yes when you set up a program and select one of the DarkGDK options some code is automatically generated and sync is on in the code.
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 3rd Jan 2013 01:56
This works! It is just putting the sync commands in the right place.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jan 2013 02:59
Your program is still incorrect.

Remove SYNC ON from the loop and place it above DO.

You should also put the WAIT and SYNC command outside your FOR loop, so place them after NEXT. This way it'll paste all 20 sprites, then wait 500ms before repositioning them again. Otherwise, you're waiting 500ms between each image and calling sync every time like that will likely erase the previous image that was just pasted so you'll never see more than 1 image at a time.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Jan 2013 03:40
Yeah, and always indent your code because it makes it easier to read and spot issues. For every branch statement, be it IF, FOR, WHILE, DO or REPEAT, in what ever language DBP, C++, C# what ever, always indent; you'll only be much kinder to yourself.

Not talking at you here, we're just helping you get better.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 5th Jan 2013 18:35
That is the way that code worked, I made the changes and it works right. I always indent code when needed. I copied and pasted this code from the book because I didn't feel like typing it any more! Thanks for the help!

Login to post a reply

Server time is: 2026-07-07 09:04:45
Your offset time is: 2026-07-07 09:04:45