

Cossu).Pages 437-497 Designing Fun Games (Sebastiano M. Cossu).Pages 381-435 Metroidvania (Part 2) (Sebastiano M. Cossu).Pages 367-380 Metroidvania (Part 1) (Sebastiano M. Cossu).Pages 297-366 Designing Platformers (Sebastiano M. Cossu).Pages 241-295 Scrolling Platformer (Sebastiano M. Cossu).Pages 231-240 Single-Screen Platformer (Sebastiano M.

Cossu).Pages 171-230 Designing Bosses (Sebastiano M. Cossu).Pages 117-169 Shoot ‘Em Up! (Sebastiano M. Cossu).Pages 87-116 Fixed Shooter (Sebastiano M. Cossu).Pages 45-85 Card Game (Part 2) (Sebastiano M. Cossu).Pages 23-44 Card Game (Part 1) (Sebastiano M.

Cossu).Pages 1-21 Hello, World! (Sebastiano M. In the Create Event of the player, we're going to use the x and y offsets to compute the distance from the center of the player to the tip of the gun, and also the angle that the gun is rotated from straight ahead, and we're going to store them in some variables so we can do a little more math with them later.Table of contents : Front Matter. YOffset = gunTipYcoordinate - playerOriginY XOffset = gunTipXcoordinate - playerOriginX Then you're going to subtract the x and y of the sprite origin from each of those values to get the base x and y offsets. Open up your player in the sprite editor and copy down (on a piece of paper or in a text editor) the x and y coordinates at the tip of the gun. (If it hasn't occurred to you yet, building games requires a well-developed understanding of all kinds of math, so best just to embrace it). You'll do this with a little trigonometry. You're feeding _bullet_x and _bullet_y into instance_create just like you should, but we need to calculate new values for _bullet_x and _bullet_y depending on what direction the player is facing. So this is the fun part (or the hard part, depending on your perspective ) Offset_angle = arcsin( y_offset / offset_distance ) // I believe this will return an angle in radians but you might look it up in the manual Offset_distance = sqrt( x_offset^2 + y_offset^2 ) If you're unsure how to get offset_distance and offset_angle, one way you could go about it is just counting the horizontal and vertical offsets in pixels in your sprite. The leading '_' characters are just a personal notation style. Good for helper variables in computations. _bullet.speed = 20 if you haven't seen 'var' before it just means a temporary variable that will be discarded when that piece of code is finished running. _bullet.direction = point_direction(_bullet_x,_bullet_y,mouse_x,mouse_y) Var _bullet = instance_create(_bullet_x,_bullet_y,obj_bullet) Var _bullet_y = y + offset_distance * sin( _player_direction + offset_angle) // use sin or dsin depending on whether your angle is in radians/degrees Var _bullet_x = x + offset_distance * cos( _player_direction + offset_angle) // use cos or dcos depending on whether your angle is in radians/degrees Var _player_direction = point_direction(x,y,mouse_x,mouse_y)
