Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2011-05-10 21:29:55

Icy EyeG
Member
From: Around Portugal
Registered: 2011-05-07
Posts: 14

My extra items

I've been making some items that I think may be useful for mods, or even for OpenSurge itself.
They're organized in a way inspired by default_startup and default_companions objects: There's a file, common.obj, that has common objects used in my projects and calls the rest of the objects in the folder extra_items, via a #require command.
This way everything is a lot tidier. smile

=== Download here ===

So the objects are:
Crushed Item Box - self-explanatory. Can be called by a custom item box, or can be added directly to the game, giving a “someone else was here before us” type feeling. smile

Empty Item Box - My attempt to emulate the built-in item boxes using the API. Doesn’t do anything, besides giving you 100 points. However, it seems that if you attack it from above, it isn’t destroyed, because OpenSurge seems to think it is a brick (due to set_obstacle TRUE command). I also added a “gravity trigger” (just like in classic Sonic games) if you attack it from bellow (and the box is suspended in the air). Unfortunately, the item box icon doesn’t pulverize like the built-in ones. Is it possible to add a pulverize command to the API?

Single Spikes – Based on the regular spikes, by Celdecea. The purpose is to make them work like the ones in Sonic 1. However, the spiking sound enters in an infinite loop in some cases, and that is something I can’t avoid.

Block Brick – an invisible brick that blocks your passage, only visible in editor mode (32x32, similar to the loop system bricks).

Safe Explosion - Only to be used as a child object, when the empty item box, or a boss is destroyed. It is also a part of the boss concept originally developed by SilverstepP.

Red ring – will take a ring from the ring count and if the ring count is already 0, it kills you.

In order to make the red rings, I edited the original rings.png and added them to it. You can replace the original, as it was designed to be 100% compatible. I also took the opportunity to add some extra big rings that correspond to the standard sizes used in various Sonic games (32px, 48px and 64px).
If you want to use them instead of the 128px big ring that comes with OpenSurge, replace these lines, under rings.spr, at sprite SD_BIGRING:

    source_rect     0 0 1024 128
    frame_size      128 128
    hot_spot        64 64

with

    source_rect     0 256 512 64
    frame_size      64 64
    hot_spot        32 32

for a 64 px big ring;

    source_rect     0 208 384 48
    frame_size      48 48
    hot_spot        24 24

for a 48 px big ring;
or

    source_rect     0 176 256 32
    frame_size      32 32
    hot_spot        16 16

for a 32 px big ring.


Note: In common.obj, you can see this line of code commented out

//#include "bosses/snowmachine.obj"

That’s for an upcoming boss I’m coding, based on SilverstepP’s boss from Mechanical Marathon (it’ll be a free substitute for Blue Ocean Zone’s boss from 0.1.4). I’ll post it here when it is completed.

Last edited by Icy EyeG (2011-05-10 23:02:58)

Offline

#2 2011-05-10 22:55:01

Sugarmaster
Member
From: Barcelona, Spain
Registered: 2011-04-26
Posts: 132
Website

Re: My extra items

Impressive.

I was meant to do the Single spikes and Block brick for my mod but you saved me time.

Thanks for the contribution!


"The true master is always learning"
Avatar by Raul Sama.

Offline

#3 2011-05-11 01:39:55

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: My extra items

Icy EyeG wrote:

Empty Item Box - My attempt to emulate the built-in item boxes using the API. Doesn’t do anything, besides giving you 100 points. However, it seems that if you attack it from above, it isn’t destroyed, because OpenSurge seems to think it is a brick (due to set_obstacle TRUE command). I also added a “gravity trigger” (just like in classic Sonic games) if you attack it from bellow (and the box is suspended in the air). Unfortunately, the item box icon doesn’t pulverize like the built-in ones. Is it possible to add a pulverize command to the API?


to avoid it acting like a brick, you can use another on_player_rect_collision in a way that the rectangle is bigger than the object. then only when the player is in that area, the object checks if its being attacked.

lets suppose your item box size is 32*32 and the animation hotspot is at 0 0.

on_player_rect_collision -4 -4 36 32 "next_state_name"

supposing O is the object this is how it would look if we could see the collision area

____
|  O  |

it has a margin on the sides and above.


this is if the hotspot is the top left corner of the sprite. based on the actual posision defined in the .spr you may have to adjust the rect_collision coordinates.


I'm not sure what you mean by "pulverize"... do you mean the noise appearing on the monitors (the white and black random dots)?

Icy EyeG wrote:

the spiking sound enters in an infinite loop in some cases, and that is something I can’t avoid.

instead of changing to "main" at the end you can add:

state "cooldown"
{
on_timeout X "main"
}

where X is an amount of time in which the object will not be active. it should be large enough so the sound does not loop when you're standing on spikes, but small enough so it goes back to "main" when the player stops flashing.

i hope this helps smile


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#4 2011-05-11 02:58:42

SilverstepP
Member
From: North Carolina
Registered: 2009-07-31
Posts: 1,545

Re: My extra items

Alexandre wrote:

I'm not sure what you mean by "pulverize"... do you mean the noise appearing on the monitors (the white and black random dots)?

Well, in simpler terms: Pulverize => break apart.

Think like the breakable blocks, where you can set how many chunks it breaks into.

Adding a feature that causes an object to break apart in that manner would actually be pretty cool. like:

object "breakable object"
{
requires 0.2.0
state "main"
{
set_obstacle "TRUE"
on_player_attack "break"
}
state "break"
{
break_object 8 8 
}
}

Like a command 'break_object' with the parameters being 'divisions x' 'divisions y'. Just like in the bricksets. I think this could be treated as a different type of 'destroy', that not only stops the object at that exact second but really shows it actually breaking and being destroyed. (So once it breaks it won't keep doing other things after its broken apart)

It seems like a small thing, but if you want to show an object getting destroyed without having to spawn a lot of 'children' pieces every time, this would be a pretty good idea. This would come in handy for some enemies that break into pieces when killed (like robots in the factory and city stages) or for certain projectiles, or for basically anything that needs to have a good explosion animation without having to do a lot of work.

Offline

#5 2011-05-11 11:27:59

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: My extra items

SilverstepP wrote:
Alexandre wrote:

I'm not sure what you mean by "pulverize"... do you mean the noise appearing on the monitors (the white and black random dots)?

please don't rename me roll

but your idea is good smile


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#6 2011-05-11 19:33:38

Icy EyeG
Member
From: Around Portugal
Registered: 2011-05-07
Posts: 14

Re: My extra items

KZR wrote:

to avoid it acting like a brick, you can use another on_player_rect_collision in a way that the rectangle is bigger than the object. then only when the player is in that area, the object checks if its being attacked.
lets suppose your item box size is 32*32 and the animation hotspot is at 0 0.
on_player_rect_collision -4 -4 36 32 "next_state_name"
supposing O is the object this is how it would look if we could see the collision area
____
|  O  |
it has a margin on the sides and above.
this is if the hotspot is the top left corner of the sprite. based on the actual posision defined in the .spr you may have to adjust the rect_collision coordinates.

Although your idea seems good in concept, I can't put it to work: I get a box that gets destroyed by contact, if I use that. I could work if we had something like on_player_rect_attack in the API (unless I misunderstood what you meant).
I think the problem is that the instruction on_player_attack doesn't override set_obstacle in the API, and it seems to do it on the built-in items (therefore, you can attack an item box, and at the same time, it is an obstacle).

SilverstepP wrote:

Like a command 'break_object' with the parameters being 'divisions x' 'divisions y'. Just like in the bricksets. I think this could be treated as a different type of ‘destroy’ that not only stops the object at that exact second but really shows it actually breaking and being destroyed. (So once it breaks it won't keep doing other things after its broken apart)
It seems like a small thing, but if you want to show an object getting destroyed without having to spawn a lot of 'children' pieces every time, this would be a pretty good idea. This would come in handy for some enemies that break into pieces when killed (like robots in the factory and city stages) or for certain projectiles, or for basically anything that needs to have a good explosion animation without having to do a lot of work.

Although I think your suggestion makes perfect sense (and is definitely an instruction that should be added to the API), what I meant by "pulverize" is the exact effect that OpenSurge uses to destroy the icon of the item boxes, once they explode. Do you think it could be achieved with a break_object 1 1 command?

Offline

#7 2011-05-11 20:08:18

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: My extra items

you have a state ending with on_player_attack "next_state"

"next_state" will invariably trigger when the player is attacking, even if not touching the object.

in that next state try using

set_obstacle FALSE

before on_player_collision

the collision still happens, and the player is attacking. that should work

Last edited by KZR (2011-05-11 20:10:13)


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#8 2011-05-11 20:23:36

SilverstepP
Member
From: North Carolina
Registered: 2009-07-31
Posts: 1,545

Re: My extra items

...what I meant by "pulverize" is the exact effect that OpenSurge uses to destroy the icon of the item boxes, once they explode. Do you think it could be achieved with a break_object 1 1 command?

I take it you mean after the icon floats up and it 'breaks apart'.

'break_object 1 1' would just cause it to fall off-screen completely intact. Depending on the icon size, if you want to truly 'pulverize' it into little 1 by 1 pixels, you need to see how the object's measurements divide up.

Say your icon is 16 by 16 pixels. If you want it to break into 1 by 1 cubes, you need to divide 16 by 1. The answer you get is 16, so it would be 'break_object 16 16'.

By that logic, if you wanted to break it into 2 by 2 cubes, you'd divide 16 by 2, and get 8, meaning 'break_object 8 8'.

The two parameters would specify how many divisions and cuts are made, not how the distance in pixels apart the divisions are. While '1 1' would seem right if you'd want pieces that are 1 by 1 pixels, the way this command works in the .brks is by specifying how many divisions are made, as above.

So break_object 2 2 would break it like this:

------------------
|         |          |
------------------
|         |          |
------------------

And break_object 4 4 would break it like this:

-----------------------------------
|         |          |           |           |

-----------------------------------
|         |          |           |           |

-----------------------------------
|         |          |           |           |

-----------------------------------
|         |          |           |           |
-----------------------------------

Offline

#9 2011-05-11 20:26:06

Sugarmaster
Member
From: Barcelona, Spain
Registered: 2011-04-26
Posts: 132
Website

Re: My extra items

I've got two things to say on the matter:

1.Break_object  1  1 is a very very good idea for the api. It would save a lot of time and create_childs.  smile

2.
>>>> EDIT: Read only if the idea from KZR doesnt work. It's just a workaround. <<<<<<<<


Although your idea seems good in concept, I can't put it to work: I get a box that gets destroyed by contact, if I use that. I could work if we had something like on_player_rect_attack in the API (unless I misunderstood what you meant).
I think the problem is that the instruction on_player_attack doesn't override set_obstacle in the API, and it seems to do it on the built-in items (therefore, you can attack an item box, and at the same time, it is an obstacle).


I think you are mixing things up a little.
If you want a solid box that only breaks when it is being attacked, you already have it.

If the problem comes when attacking from the upside doesnt work and you cannot use the on_player_rect_collision correctly you can do this:

set_obstacle in a previous state or whatever

state "upside"
{
//Gives the vertical distance between the player and the object
let "$playertoobj = player_ypos() - ypos()"

//Gives the vertical distance between the object and the player
let "$objtoplayer =  ypos() - player_ypos()"

//Subtract between the two distances 
let "$ypos =  $playertoobj - $objtoplayer"


//If [the distance between the player and the object < 10] -> check xposition of the player
if "$ypos <10" "checkposx"
}

state "checkposx"
{
//If the player is to the right of the object "checkposx2"
if "player_xpos() >= xpos()" "checkposx2"
}

state "checkposx2"
{
//Define the width of your box (i dont know why but "width()" doesnt work for my objects)
let "$objwidth = 100"

let "$offset = xpos()+ $objheight"

//If the player is inside the "offset" (position of the object + width of the object ) -> check if the player is attacking
if "player_xpos() <=  $offset" "isplayerattacking?"
}

state "isplayerattacking?"
{
on_player_attack "break" 
}

state "break"
{
set_obstacle FALSE //Stops being a brick
destroy //Change it to the state you had for "destroying" the object
}

I am reworking my code on the airflows and this little piece of code to determine the position between player and object helped me  A LOT.

It's a tricky workaround (and a very good idea from KZR) for "set_player_rect_collision" but hey, it worked! tongue

Last edited by Sugarmaster (2011-05-11 20:33:20)


"The true master is always learning"
Avatar by Raul Sama.

Offline

#10 2011-05-11 21:37:28

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,270
Website

Re: My extra items

Icy EyeG wrote:
SilverstepP wrote:

Like a command 'break_object' with the parameters being 'divisions x' 'divisions y'. Just like in the bricksets. I think this could be treated as a different type of ‘destroy’ that not only stops the object at that exact second but really shows it actually breaking and being destroyed. (So once it breaks it won't keep doing other things after its broken apart)
It seems like a small thing, but if you want to show an object getting destroyed without having to spawn a lot of 'children' pieces every time, this would be a pretty good idea. This would come in handy for some enemies that break into pieces when killed (like robots in the factory and city stages) or for certain projectiles, or for basically anything that needs to have a good explosion animation without having to do a lot of work.

Although I think your suggestion makes perfect sense (and is definitely an instruction that should be added to the API), what I meant by "pulverize" is the exact effect that OpenSurge uses to destroy the icon of the item boxes, once they explode. Do you think it could be achieved with a break_object 1 1 command?

I'm usually against very specific requests such as this one, and I decline most of them. However, I'm accepting this.

http://opensnc.sourceforge.net/wiki/ind … List#Tasks

Offline

#11 2011-05-11 23:22:51

Icy EyeG
Member
From: Around Portugal
Registered: 2011-05-07
Posts: 14

Re: My extra items

@SilverstepP, you're right, when I wrote break_object 1 1, I was thinking that the parameters were defining the size of the fragments, not the number of divisions... silly me... tongue

@Sugarmaster and KZR, I'll look into your sugestions in a few days, thanks! smile

Alexandre wrote:

I'm usually against very specific requests such as this one, and I decline most of them. However, I'm accepting this.
http://opensnc.sourceforge.net/wiki/ind … List#Tasks

Cool! Are you going to implement this only to emulate the effect of the items boxes, or a more generic approach as SilverstepB suggested? IMHO the first can be a particular case of the latter. This will be particularly useful for rewriting the Exotic Paradise boss, using the API.

Offline

#12 2011-05-11 23:31:54

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: My extra items

i think making this command generic is the way to go, so we can recreate the breaking effect in any object


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#13 2020-05-11 03:36:43

CrazyPencilDawg
Member
From: Kingston, ON
Registered: 2018-10-12
Posts: 47

Re: My extra items

I think the red rings that subtract from your ring counter were inspired by the hack OMG THE RED RINGS.


I'm making a game about a blue cartoon rat. I must have made some terrible life choices.
icon-medallion.gif

Offline

#14 2020-05-11 09:55:49

CrazyPencilDawg
Member
From: Kingston, ON
Registered: 2018-10-12
Posts: 47

Re: My extra items

You cheater! You liar! You broke my game! What a fraud! You trickster! This objects are just an imitation!


I'm making a game about a blue cartoon rat. I must have made some terrible life choices.
icon-medallion.gif

Offline

#15 2020-05-11 10:00:59

CrazyPencilDawg
Member
From: Kingston, ON
Registered: 2018-10-12
Posts: 47

Re: My extra items

...you JERK! You broke my game! mad


I'm making a game about a blue cartoon rat. I must have made some terrible life choices.
icon-medallion.gif

Offline

#16 2020-05-11 20:54:34

taotm
Member
Registered: 2020-04-19
Posts: 22

Re: My extra items

CrazyPencilDawg wrote:

...you JERK! You broke my game! mad

Hey genius. These items are 9 years old. Of course they broke your game.


professional loser

Offline

#17 2020-05-11 23:22:45

CrazyPencilDawg
Member
From: Kingston, ON
Registered: 2018-10-12
Posts: 47

Re: My extra items

taotm wrote:
CrazyPencilDawg wrote:

...you JERK! You broke my game! mad

Hey genius. These items are 9 years old. Of course they broke your game.

Sorry about the being rude and schtuff...


I'm making a game about a blue cartoon rat. I must have made some terrible life choices.
icon-medallion.gif

Offline

#18 2020-05-12 21:53:19

taotm
Member
Registered: 2020-04-19
Posts: 22

Re: My extra items

CrazyPencilDawg wrote:
taotm wrote:
CrazyPencilDawg wrote:

...you JERK! You broke my game! mad

Hey genius. These items are 9 years old. Of course they broke your game.

Sorry about the being rude and schtuff...

Its ok


professional loser

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org