Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Request]: MC Roll Engine  (Read 1299 times)

0 Members and 1 Guest are viewing this topic.

Dark-Hylian

Silence
[Request]: MC Roll Engine
« on: January 10, 2010, 02:53:33 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
I am well aware that this had been asked a bajillion times before, but can anyone help me compile a roll code? Currently I'm using an edited / revised version of Goodnight's engine, and I've come up with this.

if global.facing="R" and moving=true and holdspace=true and place_free(x+2,y) and global.rolling=false
{
x+=2;sprite_index=sprLinkRollR;global.rollfinished=false;rolling=true;
}
else if moving=true and global.rolling=true and sprite_index=sprLinkRollR and image_index=6;
{
sprite_index=sprLinkStandR;global.rollfinished=false;rolling=false
}

However, that permanenetly sets the sprite to sprLinkStandR, and if you hold space while pressing right, you slide forward indefinitely(as long as you press it). The roll sprite never comes into play at all.

Anyone think they can help? I would like to know what I'm doing wrong. Anyways, thanks in advance.  :huh:
Logged
  • Dawning Hour
Re: [Request]: MC Roll Engine
« Reply #1 on: January 10, 2010, 06:29:50 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
The coding you posted is highly inefficient. I recommend part of the GM Minish Cap Engine I made for Link's dry-land and ice-based rolling (you'll have to look for the download link which includes rolling): http://www.zfgc.com/forum/index.php?topic=34981.0
Logged

Mamoruanime

@Mamoruanime
Re: [Request]: MC Roll Engine
« Reply #2 on: January 12, 2010, 04:46:31 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
I would also suggest for the sake of some memory management change your direction vars to integers, and make constants that say "Right" "Up" "Left" or "Down". Strings are a bit too much for a value that should be numerical.

You might also want to check out the finite state machine programming model-
http://en.wikipedia.org/wiki/Finite-state_machine

Its really good for when you don't want unwanted effects, such as forcing the player to be facing right when in another action that shouldn't be able to tamper with that. It forces your objects to only go to another state (like "rolling") if the state you're in permits it.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.037 seconds with 41 queries.