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 / Sonic Rings

Author
Message
A5H73Y
10
Years of Service
User Offline
Joined: 24th May 2013
Location:
Posted: 24th May 2013 13:33
Hey guys,
Im kind of new to the whole scene but I have made a sonic clone for my college game programming unit. Its pretty good so far with the basics down (checkpoints, boss, multiple levels, animation, enemies etc).
But the thing I cant get my head around is how to add multiple rings. I can place them and collide to give you rings or whatever but is there an easier and tidier way than copy and pasting the same code over and over?
Thanks for reading
-A5H73Y

Howdy
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 24th May 2013 18:10
Quote: "easier and tidier way than copy and pasting the same code over and over?"


My suggestion would be a SpawnRing(x,y) function that will do all the code for creation (storing data in arrays and such for later retrieval as well as loading the images/sprites).

For positioning, if you don't want to position them by hand, it would probably be best to hide it in the level background image or something like that. It kinda depends on how you're doing it.

To prevent from having to load an image into things, you could hide a "Put a ring here" dot in the alpha channel of the game map. DBC can't do anything to display alpha channel data, but it is the 4th byte stored when you create a memblock from an image (Red, Green, Blue, Alpha). So if you were to load your level, then make a memblock from the level image, then scan through, spawning a ring at each point marked in the alpha channel, that should work.

Of course, there are other ways to do this, too. Depending on your method for creating your level, there are different tricks.

Hope this helps!

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Fluffy Rabbit
User Banned
Posted: 25th May 2013 08:09
Use a FOR/NEXT loop with a range of object indexes that represents what is a "ring". So, for example objects 50-100 are designated as rings, so...

for x=50 to 100
SpawnRing(rnd(500),rnd(500))
next x

A5H73Y
10
Years of Service
User Offline
Joined: 24th May 2013
Location:
Posted: 6th Jun 2013 02:34
Sorry for the late response.
Im afraid i didnt explain it well enough.
Placing the rings is no problem, the only thing is how do i manage them, for example if you collide with ring 4 it will disappear rather than keep reappearing when deleted, if that makes any sense xD
The way ive coded the game is probably considered extremely noob, but the player is static and the background moves as one object with the other level objects as other sprites.

Howdy
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2013 12:18 Edited at: 6th Jun 2013 12:31
The rings in Sonic disappear don't they? If they came back you would have thousands of them.


I'm not sure what you mean, but maybe you mean how to store them?

You can store them as Data X Y positions.

When you die you have to put them back again.

...and if you mean that you are pasting the same code over, and over again you need loops...

(Pseudo Code)...

Do
Main code here

If Level = Start
Gosub Rings
Endif

Loop

Rings:
Place rings
Read Data
Return

Data X,Y,X,Y...Ring Coordinates

That's a simplified version.

A5H73Y
10
Years of Service
User Offline
Joined: 24th May 2013
Location:
Posted: 6th Jun 2013 17:02
Okay, sorry im really bad at explaining:

in my code if i had:

sprite ring1, whatever, whatever,10
sprite ring2, whatever, whatever,10

then i said

if collide = ring1
delete sprite ring1
endif

but the sprite ring1 is still in the loop so it keeps being rewritten even though i've deleted it...
this is nothing to do with positioning of the rings so i dont need help with that.
I cant put the rings outside of the loop because their position is constantly updating due to the way ive coded the game.
I know you will probably disapprove of the way ive coded the game but whatever

Howdy
Fluffy Rabbit
User Banned
Posted: 7th Jun 2013 00:34 Edited at: 7th Jun 2013 00:37
You need to use an array that stores the status of each of your rings, including their position and whether or not they exist. If the variable/array data says a ring doesn't exist, you just don't draw it (but if you're using the Sprite commands, a DELETE SPRITE command must be called at least once, then every loop that sprite needs to avoid being drawn via some variable/array data).

The sprite commands are pretty messed up. You should consider PASTE IMAGE and a generic 2D collision algorithm/2D distance function.

Login to post a reply

Server time is: 2024-03-28 20:54:37
Your offset time is: 2024-03-28 20:54:37