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 / How do you put on sprites?

Author
Message
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 17th Nov 2010 10:58
THis has been a while since i've went back to this stuff and I've forgoten how to.Can anyone tell me and give me an example of one.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Nov 2010 10:58
Erm... Put on sprites... What does that mean?

TheComet

Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 17th Nov 2010 11:01
Ummm.... well.... i think it means like to create the sprite onto the game screen, like i don't know.Put on a sprite
Like Create sprite or something.I forget
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Nov 2010 11:06
Oh, that would be:

sprite <sprite index>,<x pos>,<y pos>,<image index>
TheComet

Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 17th Nov 2010 11:10
thanks.Is there any more to it to putting it on the programming screen?
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 17th Nov 2010 11:39
I've figured out what to say! How do I load and paste images on.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Nov 2010 12:02
sync on : sync rate 0
load image "sprite.png",1

do
cls

paste image 1,mousex(),mousey()

sync
loop

That will paste an image at the mouse position. Sprites stay where they are, unlike pasting the images which needs to be done each time the screen is cleared.

Health, Ammo, and bacon and eggs!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Nov 2010 12:10
And a more preferable way is to turn the backdrop on to avoid smearing. This allows you to get rid of the cls command:



TheComet

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Nov 2010 12:36
Why?

That would force DBPro into 3D mode, if you only need to paste images, then DBPro is faster if you don't go into 3D mode.

Health, Ammo, and bacon and eggs!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Nov 2010 15:49
Really? OK, I'd like to strike my post from the record

TheComet

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Nov 2010 18:46
I'm pretty sure that's not true any more.

On my laptop, which has crappy integrated Intel graphics, I get sprites over a second faster than pasting images (2 seconds instead of 3):


The key is to remember to disable the automatic backsave.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2010 23:16
I'm not convinced that's a helpful comparison. Wouldn't you usually want to avoid leaving a trail when a sprite moves?

In fact, if you change the demo the other way, i.e. by clearing the screen in each sync in each case, paste image is much faster (on my even crappier laptop admittedly ).

I've pasted the images/sprites in random positions to simulate movement in an application.

I get 6.5 and 14.4 seconds for the image and sprite methods respectively. Paste image wins.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Nov 2010 23:35 Edited at: 17th Nov 2010 23:39
Quote: "Wouldn't you usually want to avoid leaving a trail when a sprite moves?"

Yes, but I'd do that in exactly the same way for both images and sprites - I'd use CLS or paste in a backdrop.

However, for your code, your images and sprites are definitely not equivalent.

In your code, for images, you are clearing the screen and then pasting 100 images. Then, for sprites, you are saving the backdrop, clearing the screen, then rendering 100 sprites.

If you want to include clearing the screen (which was not part of the speed test for images vs sprites), then restore the code to as I posted it, and use CLS for both. At least then it's CLS+images vs CLS+sprites, and the comparison is equivalent.

Quote: "Paste image wins"

... but only if you stack the deck against sprites.

[EDIT]Actually, you should compare the plug-in code for each, and you'll find that PASTE IMAGE simply calls the standard sprite rendering routine for each image you paste.

Then take a look at the overhead for drawing sprites (the setting up of the rendering modes) - you'll see lots of overhead there that will be triggered for each and every PASTE IMAGE, but only once for ALL sprites.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 00:02
Quote: "Then, for sprites, you are saving the backdrop, clearing the screen, then rendering 100 sprites."


Where am I doing this additional step?

You can easily see that the screen is not being cleared by inserting something like



into the sprite loop.

Quote: "If you want to include clearing the screen (which was not part of the speed test for images vs sprites), then restore the code to as I posted it, and use CLS for both. At least then it's CLS+images vs CLS+sprites, and the comparison is equivalent.
"


I agree with that - but the sprite method (with backsave turned off) is only marginally faster on my laptop, with or without the cls.

Looks like the real lesson here is don't use the default sprite backsave feature which I guess may have been your main point.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Nov 2010 00:08
Partially, yes, but it was also 'don't write code to do what the system can already do for you'.

In the past, I carried out a fair bit of work on sprites to get them to the speed they are now, but the work doesn't stop there - if you use images instead of sprites, then you will miss the free future performance increases.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 01:03
Quote: "if you use images instead of sprites, then you will miss the free future performance increases."


Noted.
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 18th Nov 2010 06:53
does arguing normally happen or is it me?
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 18th Nov 2010 07:05
also i been having trouble with loading images.
it says CWDC:\Users\Jacob\AppData\Local\Temp LOAD IMAGES hi.png,1 then when i press ok it says Runtime Error 506-could not load image at line 2
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Nov 2010 10:49
Hehe Jacob, that's not arguing, that's a healthy discussion!

There are many ways to skin a cat in DBPro, to get images on the screen for instance you can paste em, sprite em, use plains, use a hidden bitmap and the backdrop, or use a plugin to do something similiar (but faster). They all have their place. I mean, it depends on how deeply you want to control things - sprites are good for straightforward 2D games for instance, and paste image is good for GUI's. But sprites are really the most dynamic, even more dynamic than using plains, because you can change their colour, size, aspect, UV coordinates, transparency - and then you can even paste sprites like you would an image. So paste image is good to get started, get used to the coordinate system, but then expand onto sprites as soon as you can, because usually rotation, scaling etc is needed, and Z depth sorting is often a technical headache with paste image.

Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 11:34
Quote: "does arguing normally happen or is it me?"


Yes, "arguing normally" is acceptable and happens a lot - although as Van B says we prefer the phrase "healthy discussion". It's also often the way to really get to the heart of the matter. In programming, as in most things in life, there are often several ways of doing things and different people have different knowledge and experience. In this case (as often happens ) IanM put me right and I've learnt something useful. Hopefully others have too.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Nov 2010 12:34
Quote: "There are many ways to skin a cat in DBPro"

True, also you can skin dogs, bananas and even people in DBP! It ROCKS!!!

Of course skinning cats, dogs or people might limit your market so maybe stick to bananas for the most part

Quote: "Yes, "arguing normally" is acceptable and happens a lot - although as Van B says we prefer the phrase "healthy discussion"."

I learn a lot from these discussions too. Nice to see two heavyweights having a little discussion!

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Nov 2010 14:36
Stick to facts, keep ego out of it, and it's healthy discussion that can move towards a consensus.

Quote: "Where am I doing this additional step?"

Actually, you are not, but I read your comment, and took it at face value (default is a setting of 2 which does clear the screen). It's the backsave that kills the sprite speed in your code anyway.

The backsave options are:
0 - No backsave
1 - Backsave & restore
2 - No backsave, clear to backdrop (default)

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 16:17
IanM

Quote: "default is a setting of 2 which does clear the screen"


I took the Help file at face value too (my emphasis in bold):

Quote: "If the backsave state is set to zero, the sprite will not restore its background and leave a trail as it moves. If the transparency state is set to zero, the sprite will not treat black as a transparent color. A transparent color in the sprite image does not write to the screen. If this feature is disabled, the sprite would appear as though drawn inside a black rectangle where transparency had previously been used. Both states are set to one as these are the most common settings. If you set the backsave state to zero, it is your responsibility to clear or paste the background each time the sprite is moved or animated. The sprite number should be specified using an integer value. The backsave and transparency states should be specified as either zero or one.
"


In fact there is no mention of 2 being an option.

More precisely I took that to mean that backsave = 1 is the default.

What more can a casual user do?
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 1st Dec 2010 11:30
That's ok...ay now about the healthy discussion thing and stuff.But I really want help about the "CWDC:\Users\Jacob\AppData\Local\Temp LOAD IMAGES hi.png,1 then when i press ok it says Runtime Error 506-could not load image at line 2 " stuff
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 1st Dec 2010 11:36 Edited at: 1st Dec 2010 11:37
About the healthy discussion stuff I must say-I'm a noob.It's like a language within english.I understand the words, and understand what you mean.But the way you say it is cool.I've not got to that stage of time.Anyway please note the message before and answer that instead of this becausse I REALLY NEAD HELP
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Dec 2010 11:38
Quote: "CWDC:\Users\Jacob\AppData\Local\Temp LOAD IMAGES hi.png"
?
Is that path correct? If you are using a folder that is not within the same folder as the application then it's possible you have an incorrect path/filename...

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 2nd Dec 2010 00:01
Is LOAD IMAGES supposed to be there?
Maybe you want


My computer surpasses all the technologies of the day. What computer do I have?

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Dec 2010 01:58
Quote: "does arguing normally happen or is it me?"

With the old timers on here you'll run into that from time to time, but it's all in an effort to find the most efficient programming methods.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 10:38
1. forget the normal discussion thing, it's ticking me off. click the download to see what i mean
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 10:39
And the other picture:
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 10:42
and this is what i wrote:
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Dec 2010 10:56
Staying purely on topic:
Try taking the space out of the image name "hi.png" not " hi.png"?

Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 21:10
does that make a difference?I'll try.Nup.it's still not doing it.code is again:
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 21:24
The problem is something to do with the images.I had trouble with this when I was making a game but at that time I did figure it out.Now I've forgot.I remembered most of how to paste images with putting the image file into the project folder but it won't do it.My game now is having the same problem and I've done exactly the same thing as that game that worked.PLEASE HELP
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 21:37
I worked it out.It turns out it is DBA file instead of DBPRO file.But whats the diffeerence? And can you swap DBA into DBPRO
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Dec 2010 21:51
A .DBA file contains code. A .DBPRO file contains various settings and filenames that the editor and compiler use together to produce your executable.

They are not interchangeable.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 22:08
So what am I supposed to do?If i save a code, does become always DBA,DBPRO or is it just random.Is there a way to get the file you want?
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 2nd Dec 2010 22:10
what about moving a sprite?
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 2nd Dec 2010 23:05 Edited at: 2nd Dec 2010 23:09
The .DBPro file is the Project File. It's saved when you select "Save all" or "Save Project" from the file menu. As IanM said earlier, it contains the project settings.

A .DBA file is the source code. It's saved when you select "Save", "Save all" or "Save as" from the file menu.

And for moving sprites, you should look at move sprite in the help files. Or perhaps track the x and y co'ords with some variables and use the sprite command to reposition the sprite.

>Edit<

It occurs to me that the problem you have with the media is that without creating a DBPro file (With the project settings in), it compiles and runs the program from the "Temp" folder, which isn't where the media is.

The project file tells the compiler to put the exe in the right place, which is where the media is; and so will work properly

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Dec 2010 02:01
@ Jacob_010:

You really need to look at (or review) TDKs Tutorials to lean/relearn the basics of Darkbasic.

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 3rd Dec 2010 06:08
PRof:Gee,your good.How'd you know that?
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Dec 2010 09:29
Prof has a lot of experience...

Yes, I think you should do as Grog suggested and do some basic tutorials to help get you up and running!

Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 4th Dec 2010 23:23
Yep.That's what I'm doing
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 12th Dec 2010 08:04 Edited at: 12th Dec 2010 08:04
than k ou

Edit:thatsthanl you
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 15th Dec 2010 23:41
Also something else, look
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 15th Dec 2010 23:50 Edited at: 16th Dec 2010 02:30
something else, look at this post here:. I'm actually quite sad how you guys treat me. I actually like this forum.All I want to do is learn.If I've done something bad, I'm sorry. But you guys treat me like crap. All I wanted form that post was to get the simulator working. I thought that some of the components weren't simualting because it wasn'tpro. So I posted that forum.All I got from that was crap and a slap. If I said something bad, forget it( I thought I saw something about that in the AUP) because I'm actually A nice guy. I don't want to be slapped, I want to be helped, I want to feel good making circuits and programming, not like crap.If all my posts in this forum are going to end up like that, I meanswell not go on at all, which I don't want to do because I actually like this forum, so If I do something bad, then I'm sorry, I don't meann whatever I do bad. I think I've made My point, for now.
Jacob_010
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location:
Posted: 16th Dec 2010 08:04
Also on that post I said "Is there a WAY" not how do I get it you idiots. If you say I'm bad, you guys can't read, no offence, I'm just really pissed off on how you guys treat me.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Dec 2010 09:59 Edited at: 16th Dec 2010 10:05
Firstly nobody is giving you a hard time here. Everyone who has posted on this thread was trying to help.

Secondly you are double/triple posting again which is why you got a 30 day slap from the moderators.

You really should learn to take critisism, not that anyone has critisised you in this thread only given you some good advice.

I suggest you calm down and read what has been said through again. Also maybe you should post in the "Newcomers" area for a less critical response.

EDIT: I just noticed your next response in my inbox before it gets posted (because you got slapped). You are about to get a permanent ban unless you watch your language... I am NOT an idiot, I NEVER called you 'bad' and I CAN read... "no offence"???? Good luck with that one!

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 18th Dec 2010 22:44
Quote: "AndI'm asking the questions here!"


Are you surprised you got the reaction you did?

Quote: "Why do you have a gun for LAW"


Doesn't make sense.

Quote: "Also on that post I said "Is there a WAY" not how do I get it you idiots. If you say I'm bad, you guys can't read, no offence, I'm just really pissed off on how you guys treat me."


Considering the guys are trying to help you, that's just plain ungratefulness, speaks for itself.

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 20th Dec 2010 21:24
okay so you want a straight answer, I'll give you one.
1. Make sure you are in the .dbpro file and the code is there.
2. Make sure the DBPRO and .dba file are in the same folder as "hello.png"
3. If your code is there, click "Save all..." and then hit F5
4. Make sure you don't have "sync" or "sync on" written in your program.

I attached a working version of what you want.

Now can you stop insulting everyone for trying to help?!

My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2026-07-21 07:03:46
Your offset time is: 2026-07-21 07:03:46