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 / How could I place like 100 sprites?

Author
Message
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 00:49
How could I place like 100 sprites? Without just doing this
sprite 1,blah,blah,blah
sprite 2,blah,blah,blah
blah

Read Ender's Game. And all its sequals.
Dodic
18
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 23rd Nov 2005 00:50
well , somethimes programer have to write a few lines of code.

http://dodica.proboards75.com/index.cgi
first 20 are mods. i have 9 sofar.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Nov 2005 00:52 Edited at: 23rd Nov 2005 00:52
For I = 1 to 100
Sprite I,blah,blah,blah
next I

that is why for-next loops aare soooooo cool!

Quote: "Read Ender's Game. And all its sequals."

And Artemis Fowl, and The Wheel of time, and Eragon!!!

Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 00:53
True. But I think theres another way like with the for next command? I dont know. Before I wirte all of it out, I;d like to know if theres another way...

Read Ender's Game. And all its sequals.
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 00:53
I knew it!

Read Ender's Game. And all its sequals.
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 00:54
Thanks

Read Ender's Game. And all its sequals.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Nov 2005 00:56
np

Instead of triple posting, you should edit your post...

Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 01:04
Hmm. I'm new to For Next loops, how would I make 100 sprites and place them randomly on the screen. ( x=rnd(1000) : y=rnd(480) )

Read Ender's Game. And all its sequals.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Nov 2005 01:06 Edited at: 23rd Nov 2005 01:07
For I = 1 to 100
Sprite I,rnd(640),rnd(480),image number
next I

The random stuff doesn't have anything to do with the for-next loop.

Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 01:11
That works great! OK, one more thing. I need to be able to adjust the different x and y values of the sprites. (sorry!)

Read Ender's Game. And all its sequals.
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 01:11
Artemis Fowl is good, and so is Eragon.

Read Ender's Game. And all its sequals.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Nov 2005 01:11 Edited at: 23rd Nov 2005 01:13
Quote: "I need to be able to adjust the different x and y values of the sprites"

What do you mean?

Quote: " Artemis Fowl is good, and so is Eragon."



I'll be back in about 15 minutes...

Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 01:14
Well since the sprites are just set at random, with no variables, there are no variables to change.

Read Ender's Game. And all its sequals.
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 23rd Nov 2005 01:27




UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Nov 2005 01:27
Sorry can't help right now. Stupid little sister!!! AARRRGGGHHH. I will be able to help tomorrow(about 10 hours) sorry.

Use arrays for the variables(look in help) Make the array the random stuff...

Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 01:33
Thanks for all the fast help guys!
@ Antidote

Hmmm. But if I use that, I will move every one of the sprites if I change the x or y. I need to do it individually. Gosh, sorry for bein so picky.

Read Ender's Game. And all its sequals.
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 23rd Nov 2005 02:02
use arrays.

An array is a bunch of data all stored under the same variable name and referenced my a number.

so the first thing we would need to do is this



What this does is it makes defines the variables xpos and ypos as arrays with 100 spaces to store data

so when you first put the sprites on the screen you would do this



This will set the array values and position the sprites at those values. Then the values in the array can be called at any time and changed at any time by doing something like this



Now I have used a few commands that you probably haven't seen before. Here they are and the descriptions

Screen width() - returns the maximum x position in pixels of the screen

Screen height() - returns the maximum y position in pixels of the screen

str$(value) - Returns the string value of any not string value. This is used because the text commands only allows for output of strings so we have to convert the integer data in the array.



Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 23rd Nov 2005 02:28
OK thanks.

Read Ender's Game. And all its sequals.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Nov 2005 08:11
If you don't want to put them in an array you can check a sprites x and y by using "sprite x(spritenumber)" and "sprite y(spritenumber)". Those commands exist because Darkbasic already tracks where all the sprites are.

Login to post a reply

Server time is: 2024-09-24 09:37:06
Your offset time is: 2024-09-24 09:37:06