Okay so continuing from before, now I have successfully finished adding code for moving forward, wrapping it over the screen, a little something for smooth projectile rotation, logical shooting and objects at random to collide and shoot at?
I kinda got carried away with the game making that I ended up forgetting to document my moves and since I am currently packed with finding a domain for my project I am not gonna redo it and document it, I’ll most probably don one when I am free-er… *sigh
Trying to refresh:
- Start a new project
- Create a room
- Create a sprite for the ship
- Add the sprite to the Object
- Add events to the Object
- left key image_angle = image_angle +2;
- right key image_angle = image_angle +2;
- up key motion_add(image_angle,0.2);if (speed > 5) speed = 5;
- other-Outside room Drag and drop the wrap around the window thing?
- step speed = max (speed – 0.1,0)
- Add the Object to the Room
- Run the code using F5
Okay so from here, I added a new sprite (a few sprites) for the rock objects that need to be shot or collided with.
Create event : image_speed = 0;image_index = irandom(2);
Okay, why random? Cause I made multiple frames of the Asteroid so instead of animating (changing shape) it I placed it randomly on the screen and made the rocks to be of different shape throughout the game and gave it some speed. Now to deal with collision and death.
The asteroid can collide with either the Ship, the Bullet (another sprite that I thought I need not mention), another Asteroid or the wall.
Adding the collision events:
Click on the add events for the Asteroid and on clicking the Collision button choose the objects (ship, asteroid, bullet) for which the action is triggered?
Bullet : instance_destroy();
Ship : Drag and drop the Game Restart code…
I was thinking of colliding with the wall and bouncing off of it, but I am just gonna wrap it around the walls ; just like I did with the ship. And likewise for the bullet, for the outside room I added the instance_destroy(); cause I didn’t want the bullet to wrap around else it would become too messy.
Bullet Events and corresponding Actions:
Outside the room : instance_destroy();
Space bar click event : bullet = instance_create(x,y,obj_bullet); bullet.speed = 15; bullet.direction = image_angle;