Difference between revisions of "PRJ-Motion:Skins"
Line 10: | Line 10: | ||
[[File:Lisa-Johnson-Run.gif|Lisa Johnson's running animation]] | [[File:Lisa-Johnson-Run.gif|Lisa Johnson's running animation]] | ||
− | + | That's the theory to how Motion handles its player skins, anyway. | |
+ | |||
+ | ==Programming Sprite Changes== | ||
+ | |||
+ | SAMPLE | ||
+ | |||
+ | <pre> | ||
+ | |||
+ | |||
+ | |||
+ | void CPlayer::think(){ | ||
+ | velx=0; //don't move left / right by default | ||
+ | |||
+ | if(keystates[SDLK_RIGHT]){ | ||
+ | faceright = true; //player graphic is facing right | ||
+ | if(keystates[SDLK_x]){ | ||
+ | velx = runVel; //run right | ||
+ | if(PGFX < 5 && !jumping || PGFX == 11) | ||
+ | PGFX = 6; | ||
+ | elseif(PGFX == 6 && !jumping) | ||
+ | PGFX = 7; | ||
+ | elseif(PGFX == 7 && !jumping) | ||
+ | PGFX = 8; | ||
+ | elseif(PGFX == 8 && !jumping) | ||
+ | PGFX = 8; | ||
+ | elseif(PGFX == 8 && !jumping) | ||
+ | PGFX = 9; | ||
+ | elseif(PGFX == 9 && !jumping) | ||
+ | PGFX = 10; | ||
+ | elseif(PGFX == 10 && !jumping) | ||
+ | PGFX = 11; | ||
+ | } | ||
+ | else{ | ||
+ | velx = walkVel; //walk right | ||
+ | |||
+ | } | ||
+ | if(keystates[SDLK_LEFT]){ | ||
+ | faceright = false; //player graphic is facing right | ||
+ | if(keystates[SDLK_x]) | ||
+ | velx = -runVel; //run left | ||
+ | if(PGFX < 5 && !jumping || PGFX == 11) | ||
+ | PGFX = 6; | ||
+ | elseif(PGFX == 6 && !jumping) | ||
+ | PGFX = 7; | ||
+ | elseif(PGFX == 7 && !jumping) | ||
+ | PGFX = 8; | ||
+ | elseif(PGFX == 8 && !jumping) | ||
+ | PGFX = 8; | ||
+ | elseif(PGFX == 8 && !jumping) | ||
+ | PGFX = 9; | ||
+ | elseif(PGFX == 9 && !jumping) | ||
+ | PGFX = 10; | ||
+ | elseif(PGFX == 10 && !jumping) | ||
+ | PGFX = 11; | ||
+ | |||
+ | else | ||
+ | velx = -walkVel; //walk left | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | TO BE REWRITTEN |
Latest revision as of 06:35, 31 December 2013
Motion: Skins
Motion will be programmed in such a way that characters can be represented on sprite sheets that a single image file. The skin image is loaded at any given time, but each sprite from the file is blitted and shown, instead of the entire image. With the low resolution graphic style of the game, it is an uncomplicated matter for players to quickly and easily create their own player skins to import into the game.
One file has twelve sprites, as opposed to twelve individual sprites in twelve individual files in some folder. The way the program works, the player skin is preloaded into memory and simply only has to show a blitted portion of the graphic. The program simply would not run as efficiently if it had to load and show one of twelve different image files per frame, because it would also have to unload the previous image file before it could then load and show show the new one.
This is the Lisa sprite, one of the default skins to be included/hard-coded into the game. The top row has, from left to right, Standing, Walking 1, Walking 2, Jumping, Falling, and Wall-Slide. The bottom row has six frames for the running animation:
That's the theory to how Motion handles its player skins, anyway.
Programming Sprite Changes
SAMPLE
void CPlayer::think(){ velx=0; //don't move left / right by default if(keystates[SDLK_RIGHT]){ faceright = true; //player graphic is facing right if(keystates[SDLK_x]){ velx = runVel; //run right if(PGFX < 5 && !jumping || PGFX == 11) PGFX = 6; elseif(PGFX == 6 && !jumping) PGFX = 7; elseif(PGFX == 7 && !jumping) PGFX = 8; elseif(PGFX == 8 && !jumping) PGFX = 8; elseif(PGFX == 8 && !jumping) PGFX = 9; elseif(PGFX == 9 && !jumping) PGFX = 10; elseif(PGFX == 10 && !jumping) PGFX = 11; } else{ velx = walkVel; //walk right } if(keystates[SDLK_LEFT]){ faceright = false; //player graphic is facing right if(keystates[SDLK_x]) velx = -runVel; //run left if(PGFX < 5 && !jumping || PGFX == 11) PGFX = 6; elseif(PGFX == 6 && !jumping) PGFX = 7; elseif(PGFX == 7 && !jumping) PGFX = 8; elseif(PGFX == 8 && !jumping) PGFX = 8; elseif(PGFX == 8 && !jumping) PGFX = 9; elseif(PGFX == 9 && !jumping) PGFX = 10; elseif(PGFX == 10 && !jumping) PGFX = 11; else velx = -walkVel; //walk left } }
TO BE REWRITTEN