First of all, I went ahead and changed all the global.state codes.
Why confuse yourself with numbers, global.state=0, global.state=1,etc. I just changed them to:
Code:
global.state="small"
global.state="big"
etc
On The Create Event Added:
Code:
sprite="walk"
global.character="mario"
On the Drawing Event
Code:
execute_string("sprite_index=spr_"+global.character+"_"+global.powerup+"_"+sprite)
Changed every sprite_index=sprite_image_here to sprite="pose here". For example, instead of having this:
Code:
if global.state = 0
sprite_index = spr_mario_small_walk
if global.state = 1
sprite_index = spr_mario_big_walk
if global.state = 2
sprite_index = spr_mario_fire_walk
if global.state = 3
sprite_index = spr_mario_hammer_walk
if global.state = 4
sprite_index = spr_mario_leaf_walk
if global.state = 5
sprite_index = spr_mario_tanooki_walk
if global.state = 6
sprite_index = spr_mario_frog_walk
if global.state = 7
sprite_index = spr_mario_bomb_walk
if global.state = 8
sprite_index = spr_mario_ice_walk
if global.state = 9
sprite_index = spr_mario_super_walk
if global.state = 10
sprite_index = spr_mario_carrot_walk
if global.state = 11
sprite_index = spr_mario_ninja_walk
if global.state = 12
sprite_index = spr_mario_bee_walk
if global.state = 13
sprite_index = spr_mario_shell_walk
if global.state = 14
sprite_index = spr_mario_penguin_walk
All you need is this:
Code:
sprite="walk"
The Code on the Drawing Event will take care of everything.
As long as the sprites are named like you have them:
Let's say you wanna make Mario show the small walking sprite:
Quote:
spr_mario_small_walk
All you have to do is this:
Code:
sprite="walk"
Just the last part of the sprite's name. No need to make a code for each power up either since the are all named the same.
The Drawing event draws "spr_" Plus the global.character Plus the Powerup/State he is in Plus "sprite" which is the pose,
If you Add another Character like let's say, Luigi. All you have to do is rename the sprites where it says mario to luigi, ex:
Quote:
spr_mario_small_walk
spr_luigi_small_walk
And have an event/code change the global.character="mario" to global.character="luigi".
You can even use that global.character to have specific features for each character in just one object(obj_mario).
It's kind of basic, can be done easier but at least with just those 3 Lines of Code (2 on the create event and 1 on the drawing event)
you can get rid of:
Quote:
scr_mariowalk
scr_mariojump
scr_mariorun
scr_mariorunjump
scr_marioclimb
scr_mariohold
scr_mariocarry
scr_mariowap
scr_mariogoal
scr_marioslide
And Turn:
Quote:
scr_smallmario
scr_bigmario
scr_firemario
scr_hammermario
scr_leafmario
scr_tanookimario
scr_frogmario
scr_bombmario
scr_icemario
scr_supermario
scr_carrotmario
scr_ninjamario
scr_beemario
scr_shellmario
scr_penguinmario
Into just one script.
PS: This will make it easier to add power ups later too, let's say you add... the squirrel power up. just name the sprites with all the poses like the ones on the engine already are:
Quote:
spr_mario_fire_walk
Into:
Quote:
spr_mario_squirrel_walk
And have an item that makes mario's global.state turn into:
Quote:
global.state"squirrel"
The rest is Self-explanatory