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 2010-12-27 14:28:17

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

Projectile system WIP

idk about you, but i like shooting stuff big_smile

this is a very rough projectile system that replaces the "change player" key with a "shoot" key.
this is mainly mod-oriented, as i believe Open Surge will have no shooting sequences.

Bugs abound, and i'd like to have some help if possible.

Known bugs:

Attached object lags behind as mentioned in another thread. this makes the projectiles spawn incorrectly especially when jumping.
Projectiles only go right.
Powerups are broken atm
you start at power level 1 instead of 0 but this is a temporary issue. it's gonna be fixed

OBJ

object "powerup"
{
requires 0.2.0
    state "main"
    {
    set_animation "powerup" 0
    on_player_collision "powerup"
    }
    state "powerup"
    {
    let "$_shot_power += 1"
    destroy
    }
}

object "weapons"
{
hide_unless_in_editor_mode 
requires 0.2.0
    state "main"
    {
    let "$_disable_character_switching = 1"
    attach_to_player
    on_button_down "fire2" "shoot"
    }
    state "shoot"
    {
    if "$_shot_power = 0" "punch"
    if "$_shot_power = 1" "kunai"
    if "$_shot_power = 2" "shuriken"
    if "$_shot_power = 3" "fireball"
    if "$_shot_power = 4" "firekunai"
    if "$_shot_power = 5" "fireshuriken"
    }
    state "punch"
    {
    create_child ".punch" 16 -16
    change_state "cooldown"
    }
    state "kunai"
    {
    create_child ".kunai" 16 -16 
    change_state "cooldown"
    }
    state "shuriken"
    {
    create_child ".shuriken" 16 -16 
    change_state "cooldown"
    }
    state "fireball"
    {
    create_child ".fireball" 16 -16 
    change_state "cooldown"
    }
    state "firekunai"
    {
    create_child ".firekunai" 16 -16 
    change_state "cooldown"
    }
    state "fireshuriken"
    {
    create_child ".fireshuriken" 16 -16 
    change_state "cooldown"
    }
    state "cooldown"
    {
    on_timeout 0.25 "main"
    }
}

object ".punch"
{
    state "main"
    {
    set_animation "punch" 0
    on_timeout 0.2 "destroy"
    }
    state "destroy"
    {
    destroy
    }
}

object ".kunai"
{
    state "main"
    {
    set_animation "kunai" 0
    bullet_trajectory 400 0
    on_right_wall_collision "destroy"
    on_left_wall_collision "destroy"
    on_floor_collision "destroy"
    on_ceiling_collision "destroy"
    on_timeout 5 "destroy"
    }
    state "destroy"
    {
    destroy
    }
}
object ".shuriken"
{
    state "main"
    {
    set_animation "shuriken" 0
    bullet_trajectory 400 0
    on_right_wall_collision "destroy"
    on_left_wall_collision "destroy"
    on_floor_collision "destroy"
    on_ceiling_collision "destroy"
    on_timeout 5 "destroy"
    }
    state "destroy"
    {
    destroy
    }
}
object ".fireball"
{
    state "main"
    {
    set_animation "fireball" 0
    bullet_trajectory 400 0
    on_right_wall_collision "destroy"
    on_left_wall_collision "destroy"
    on_floor_collision "destroy"
    on_ceiling_collision "destroy"
    on_timeout 5 "destroy"
    }
    state "destroy"
    {
    destroy
    }
}
object ".firekunai"
{
    state "main"
    {
    set_animation "firekunai" 0
    bullet_trajectory 400 0
    on_right_wall_collision "destroy"
    on_left_wall_collision "destroy"
    on_floor_collision "destroy"
    on_ceiling_collision "destroy"
    on_timeout 5 "destroy"
    }
    state "destroy"
    {
    destroy
    }
}
object ".fireshuriken"
{
    state "main"
    {
    set_animation "fireshuriken" 0
    bullet_trajectory 400 0
    on_right_wall_collision "destroy"
    on_left_wall_collision "destroy"
    on_floor_collision "destroy"
    on_ceiling_collision "destroy"
    on_timeout 5 "destroy"
    }
    state "destroy"
    {
    destroy
    }
}

SPR

sprite powerup
{
    source_file     images/shots.png
    source_rect     48 0 16 16
    frame_size      16 16
    hot_spot        16 16

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1
    }
}
sprite kunai
{
    source_file     images/shots.png
    source_rect     0 0 16 16
    frame_size      16 8
    hot_spot        16 4

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1
    }
}
sprite shuriken
{
    source_file     images/shots.png
    source_rect     0 32 48 64
    frame_size      16 16
    hot_spot        8 8

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1 2
    }
}
sprite fireshuriken
{
    source_file     images/shots.png
    source_rect     0 48 48 64
    frame_size      16 16
    hot_spot        8 8

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1 2
    }
}
sprite firekunai
{
    source_file     images/shots.png
    source_rect     16 0 16 16
    frame_size      16 8
    hot_spot        16 4

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1
    }
}
sprite fireball
{
    source_file     images/shots.png
    source_rect     0 16 16 16
    frame_size      16 8
    hot_spot        16 4

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1
    }
}
sprite punch
{
    source_file     images/shots.png
    source_rect     16 16 16 16
    frame_size      16 8
    hot_spot        16 4

    // default
    animation 0
    {
        repeat      TRUE
        fps         8
        data        0 1
    }
}

PNG

shots.png


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

Offline

#2 2010-12-27 14:55:40

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

Re: Projectile system WIP

I KNEW IT. IT WON'T TAKE LONG 'TILL YOU GUYS COME UP WITH A SPACESHOOTER. roll

jk.

Nice, man. smile You can study Lady Bugsy in order to know how to make projectiles go left or right.

I wonder if you drew the PNG youself. If you did, we could use that in Open Surge (when enemies and bosses shoot things), if you authorize of course.

Offline

#3 2010-12-27 14:59:32

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

Re: Projectile system WIP

i didn't draw this png, i used some rips to save time and go straight to the scripts, but i intend to do the final one from scratch, and i can draw as many projectiles as you have in mind roll


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

Offline

#4 2010-12-27 17:23:28

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

Re: Projectile system WIP

Alexandre wrote:

I KNEW IT. IT WON'T TAKE LONG 'TILL YOU GUYS COME UP WITH A SPACESHOOTER. roll

I DIDN'T DO ANYTHING I SWEAR! I DIDN'T MAKE A SUPER FORM LEVEL THAT INVOLVES YOU SHOOTING STUFF AND DODGING SPIKES IN SPACE!

blatant_lies.jpg

Anyhow, regardless. I'd like to see these powers combined with shields.

Last edited by SilverstepP (2010-12-27 17:28:01)

Offline

#5 2010-12-31 04:19:14

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

Re: Projectile system WIP

here's what the projectile system was meant to do:

http://www.youtube.com/watch?v=gfI4w_tbjnE

I'm tuning it up. there will be a good version up soon


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

Offline

#6 2011-04-27 08:22:25

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

Re: Projectile system WIP

This could be even better if you added an animation for throwing shurikens.

Can you do that with "set_player_animation" ?

I think i will try this out in my mod....


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

Offline

#7 2011-04-27 12:34:10

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

Re: Projectile system WIP

yes, set_player_animation works that way. although this script is very old. it dates from the beggining of my mod, when i did the first throwable weapons. The obkects are now a bit more complex, they can be thrown diagonally, and react to character stats, as well as having separate ammo counters, and ammo pick-ups, something that Open Surge does not use. i can provide you a copy of the script if you're interested, but it would need some bits adapted to work with different mods, or original Open Surge.
But for your shooting pleasure it works well enough. if you change graphics you can do anything from bullets to lasers, and with a bit of scripting you can even turn it into a machine gun or shotgun, just by reducing cooldown time and scripting variable movement on the projectiles. oh, i'm ranting tongue let me know if you want the files. you can find them and much more if you download my mod (follow the signature link). You can learn from them and transform them any way you like smile

Last edited by KZR (2011-04-27 12:35:21)


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

Offline

#8 2011-04-27 13:19:27

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

Re: Projectile system WIP

Thanks for the help KZR, i'm studying the "fire_magic.obj" from your script as an example of projectile.

Some awesome scripts you've got set up wink.

I think i'll make Sonic throw his rings, it's just an idea but I'll post the results as soon as it's completed.

Do you recommend me to study a particular script in your game or this one is good for my interests?


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

Offline

#9 2011-04-27 17:04:13

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

Re: Projectile system WIP

the way they are set up may be hard to figure for a beginner, but the base for a good projectile system is:

-reserving a button for that

-having an object dedicated to read the keys pressed (commands "on_button_pressed", "on_button_down")

-making that object spawn bullets (command "create_child")

-having bullet objects that:
*move themselves (command "move")
*destroy themselves when colliding with certain objects( commands "on_collision", "destroy")

there is a file in objects/default_startup called combat.inc. there you will find objects ".player_shot_tracker" (button reader) and ".player_shot" (the bullets). that's probably the best place to start. magic works the same way with different conditions, but its deactivated. you may study it but its likely that it is not what you're looking for.


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

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org