Today i created another simple game in where a character moves left and right and attacks an enemy
For my "good guy" character i used Popeye
Due to the fact that the image is a png and i cannot create animations so this character model when moving would stay stagnant
Here is the Code i used to make him move right, It used an input "when key is pressed" the key in order to move him right is the right arrow key, his movement speed is 20
However if i just had this the character would not be able to decelerate meaning once you started moving him he wouldn't stop so i added this code to counteract this. It just makes it so when the right arrow key is released the character stops moving.
Now we cant just have a character moving right, so here is the code for moving left, how it works is that due to the negate command it actually means that when the left arrow is pressed the character is moving negative 20 x or backwards.
Yet again i have to add a way so that the character stops moving, here is the code its the same as before but for left.
Now we cant have a character game without bad guys so i decided to use Bluto here is the image i used
Now in order to help him now at the same time as Popeye i have given him his own set movement controls
*Left is identical so i didn't include it
He moves parallel to Popeye and the reason for the gravity is so that he doesn't float around when keys aren't being pressed, Popeye doesn't do this because the controls are centralized around him.
Now i need a tile set in order to make a proper scene.
Tomorrow i plan on creating a scene and creating attacks for both of characters.
No comments:
Post a Comment