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 2014-07-30 22:23:22

jano
Member
Registered: 2014-07-24
Posts: 11

Spindash/"charging"-speed

Hi everyone,
as I wrote in my old topic, I started creating a little mod based on this version of Open Surge. I wanted to use high resolution sprites, so I changed the resolution in src/core/video.c. It worked fine, but of course, in comparison to the screen size, the characters ran very slow. So I changed the variables in src/entities/physics/psysicsactor.c – running, jumping and rolling is fine, but I didn't find a variable to increase spin dash (or how it's called in surge.spr: charging) - speed, which is still very slow.

Does anyone of you know which part of the source code controls the spin dash speed?

Thank you!

Kind regards,
Jano

Offline

#2 2014-07-31 10:32:06

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

Re: Spindash/"charging"-speed

i can not say 100% sure right now, but I believe that the spindash is controlled by a script. somewhere in the objects folder there should be a script for spindashing.

to change player speed variables, it's easier that you change the .chr files. you can then have different values for different characters, and you don't neet to recompile the engine.

For the resolution, though, that's the only way. You should also change the screen size somewhere in level.c, if memory does not fail me.


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

Offline

#3 2014-08-02 16:25:30

jano
Member
Registered: 2014-07-24
Posts: 11

Re: Spindash/"charging"-speed

Hey KZR,
thank you very much, it worked, I can control the spindash speed now. But I have got another question:

I still can't control th deceleration that happens, while the player runs, but I stop holding the button (The "dec"-variable only controls the braking speed, if I press the button for another direction than the player runs). I tried out all variables I know, including the ones you wrote about...

Offline

#4 2014-08-02 16:50:07

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

Re: Spindash/"charging"-speed

oh, that deceleration, i think that's in the engine code. something like friction or frc. The controls are a bit twitchy, I hope that gets reviewed later in a release, because as it stands now, we must create scripts to handle some details, and that's not how it should be, in my opinion.
I had some problems with deceleration myself, and I had to create a set of hack scripts to give me full control over the player's movement, which is not actually fun.

This is what I did. Copy to a new text file inside the objects folder, and rename it speedhack.obj.

// ---------------------------------------------------------
// *Object Name:* speedhack
// *Author:* Fracture
// *Designed for:* Shinobi Densetsu
// *Description:* Controls and hacks player's deceleration. further than what the built-in multipliers allow.
// *Version:* SD Alpha 1
// *Last modded by:* KZR, date undetermined
// ---------------------------------------------------------
    
    object ".speedhack"
    {
    
        always_active

        state "main"
        {
            hide
                        
                        let " $stop_threshold = 32"
            let " $multiplier = dt()*player_direction()*128"
            let " $multiplier2 = $multiplier/1.5"
            
            on_player_in_the_air "main"
            on_player_brake "main"
            
            on_button_down "left" "check"
            on_button_down "right" "check"
        }

        state "check"
        {
            on_player_in_the_air "main"
            on_player_brake "main"

            on_button_up "right" "decel"
            on_button_up "left" "decel"
        }

        state "decel"
        {
            on_player_brake "main"
            on_player_in_the_air "main"

            on_button_down "left" "check"
            on_button_down "right" "check"

            let " $speed = player_xspeed()"

            if "(player_angle() > 45) and (player_angle() < 315)" "main"

            if "abs($speed) < $stop_threshold" "stop"
            if "abs($speed) < 128" "decel_half"
            if "abs($speed) < 270" "decel_normal"
            if "abs($speed) < 270" "decel_double"

            change_state "main"
        }

        state "decel_double"
        {
            on_player_in_the_air "main"
            on_player_brake "main"

            on_button_down "left" "check"
            on_button_down "right" "check"

            let " $multiplier = dt()*player_direction()*128"

            set_player_xspeed "player_xspeed()-$multiplier*2"

            return_to_previous_state
        }

        state "decel_normal"
        {
            on_player_in_the_air "main"
            on_player_brake "main"

            on_button_down "left" "check"
            on_button_down "right" "check"

            let " $multiplier = dt()*player_direction()*128"

            set_player_xspeed "player_xspeed()-$multiplier*1.5"

            return_to_previous_state
        }

        state "decel_half"
        {
            on_player_in_the_air "main"
            on_player_brake "main"

            on_button_down "left" "check"
            on_button_down "right" "check"

            let " $multiplier = dt()*player_direction()*128"

            set_player_xspeed "player_xspeed()-$multiplier"

            return_to_previous_state
        }

        state "stop"
        {
            on_player_in_the_air "main"

            set_player_xspeed 0

            on_player_brake "main"

            change_state "main"
        }

    }

You just make the companion object for your player do:

create_child ".speedhack"

Your topspeed values in the .chr file are probably different than mine. You may need to play with this section:

if "abs($speed) < 128" "decel_half"
if "abs($speed) < 270" "decel_normal"
if "abs($speed) < 270" "decel_double"

It's also not guaranteed that my script works 100% like you wish, since my engine is heavily modified, but give it a try and let me know if the player behaves better smile

Last edited by KZR (2014-08-02 16:52:52)


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

Offline

#5 2014-08-02 19:59:10

jano
Member
Registered: 2014-07-24
Posts: 11

Re: Spindash/"charging"-speed

KZR wrote:

oh, that deceleration, i think that's in the engine code. something like friction or frc.

Thank you for your extensive reply. I tried out the frc-variable before, but I didn't notice wich effect it had – it controlled the friction at the beginning of the braking, but in the end, the friction was nerly zero, so the player went veeery slow, but he didn't stop. I fixed it, now, by deleting the dt-mutliplier int the physicsactor.c at

if(!(fabs(pa->gsp) < walk_threshold && pa->angle == 0x0))
               pa->gsp -= min(fabs(pa->gsp), pa->frc) * sign(pa->gsp) /* dt*/;

I don't know which use it had, but now, the braking works fine for me.


The controls are a bit twitchy, I hope that gets reviewed later in a release, because as it stands now, we must create scripts to handle some details, and that's not how it should be, in my opinion.
I had some problems with deceleration myself, and I had to create a set of hack scripts to give me full control over the player's movement, which is not actually fun.

This is what I did. Copy to a new text file inside the objects folder, and rename it speedhack.obj.

You just make the companion object for your player do:

create_child ".speedhack"

Your topspeed values in the .chr file are probably different than mine. You may need to play with this section:

if "abs($speed) < 128" "decel_half"
if "abs($speed) < 270" "decel_normal"
if "abs($speed) < 270" "decel_double"

It's also not guaranteed that my script works 100% like you wish, since my engine is heavily modified, but give it a try and let me know if the player behaves better smile

I'm sorry, I didn't notice an effect... I crated the speedhack.obj and I added create_child ".speedhack" in the main state of surge.obj. Nothing changed after starting the game. At the moment, I don't even have time to play with those numbers – I'm going to tell you as soon as possible, if it works and which modification was needed.

What should the speedhack improve exactly?

Have a nice weekend!

Jano

Offline

#6 2014-08-02 21:57:42

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

Re: Spindash/"charging"-speed

it should improve the deceleration, especially at low speeds, so that, for example, when you are walking slowly to the left and then press right, the character will not suddenly walk fast in that direction. A little hard to explain, but it means you get more precision and it does not feel so much like walking on ice.


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