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 Discussion / Multiple identical sprites?

Author
Message
7oybox
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location:
Posted: 13th Jul 2004 07:21
I hate being a n00b.

I'm working on a simple, sprite-based 2D game in which I want about 10 or 20 of the same image to be placed at random points on the screen. I've never been good with arrays, and I imagine that arrays are how I'm going to have to go about doing this. I've included a very, VERY basic snippit that shows how I'm positioning the one I have to work with. Basically, I need to use an array for two things:

1) Create multiple copies of one image, i.e.

dim g(20)
load image "grave.bmp",g

2) Use only a few lines of code to create a random position for each of those images.

Anyone help? I'll be glad to include you in the 'credits.' Thanks!

I will eat your flesh.
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 13th Jul 2004 08:00
You dont have to use arrays for identical sprites, because this will also work:


load image "smiley.bmp", 1

sprite 1, 0, 0, 1
sprite 2, 0, 0, 1
sprite 3, 0, 0, 1


voila, 3 smiley sprites

Btw, if you dont know how arrays work, you can read a tutorial at my site (link under my signature)

7oybox
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location:
Posted: 13th Jul 2004 09:47
Hmm. Simple enough. Could you do me a favour and explain to me what each of the four numbers in those lines represent?

I will eat your flesh.
7oybox
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location:
Posted: 13th Jul 2004 10:01
Okay, nevermind, figured that out. I got kind of a problem though. For some reason, there's a copy of the sprite up in the very top-left corner of the screen that isn't included as one of the random sprites. Check it out in the code.

I will eat your flesh.

Login to post a reply

Server time is: 2025-05-24 22:39:10
Your offset time is: 2025-05-24 22:39:10