260 likes | 361 Views
Backgrounds, Inheritance in GameMaker (BrickMania 1 of 2). Foundations of Interactive Game Design Professor Jim Whitehead January 28, 2008. Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0. Upcoming Assignments. Wednesday: Game Concept Document
E N D
Backgrounds, Inheritance in GameMaker (BrickMania 1 of 2) Foundations of Interactive Game Design Professor Jim Whitehead January 28, 2008 Creative Commons Attribution 3.0creativecommons.org/licenses/by/3.0
Upcoming Assignments • Wednesday: Game Concept Document • A compelling document that sells your game concept • Title page • Title of game, name of group, name of team members, sample artwork • Overview page • Table at top: game genre, platform (PC/GameMaker, PC/RPG Maker, etc.), team size • Key points section • Bulleted list of important elements of gameplay • Goal of game, what makes game unique, main characters, main fictional elements • Sample artwork image to give feel of the game • Biographies • True, pocket biographies of each team member (1-2 paragraphs each) stressing experience that makes you a strong game designer • 1-3 pages giving a textual description of the game • Fictional background, brief description of characters, goal of player in game, how does player interact with the game, brief description of levels, game audience, other important elements as needed. • 1-2 pages of sample conceptual artwork • Hand-drawn sketches are fine • Start early!
Let’s create a simple Breakout game • Game elements • Background • Ball • Paddle • Score • Lives • 3 brick types • Playfield issmaller thanscreen
Backgrounds • Background • Represents a static background image • Defined separately, then combined with a room • Can move, or be motionless • Many uses • Moving starfield • Create starfield bitmap image • Define as background • Have it move backwards: creates sensation of motion • Image surrounding playfield of game • BreakMania uses a background this way
Detecting edges of background • Reduce boundary objects • In tile-based games, need many tiles to create an interesting level • With objects, would need separate object for each tile type • Can slow a game down • Instead, create background image • Then, use single, invisible boundary object for collision detection • Can be easier to create background in drawing program • Then, just use simple shapes for collision detection • May be easier than converting to tiles at times
Creating a Background • Resources -> Create Background • Enter name • Can have a transparent color • Useful for multi-depth scrolling background • Load backgroundimage • Select file
Break Mania Background • Created usingThe GIMP • Free software • PC & Mac • Used fills &text effectsthat comewith GIMP score box playfield
Create Room • Resources -> Create Room • Click on “Settings Tab” … enter name of Room
Add Background to Room • Unselect “Draw background color” • Select“Visible whenroom starts” • Use pull-downmenu toselectbackgroundimage Select grid size to match size of sprites – for us, 10x10 works well Note grid alignment with background image boundaries – need to plan ahead for this!
Create Sprites • For BreakMania need sprites for: • Paddle • Ball • Three brick types • Small paddle (for lives display) • Three different wall types • Two different vertical (10x50,10x30), & one horizontal (10x50) • Used to create invisible barrier for edge of playfield • Game over text
Create Objects • For most of the sprites, need to create an associated object • Resources -> Create Object • Solid: Paddle, three brick objects, three wall objects • Not solid: Ball, game over • No need to create small paddle object • Only need to use the sprite for lives display • For now, no behavior • Will add soon
Create Invisible Objects • Three wall types all must be invisible • Will place them over the background • Ball will collide with invisible wall objects • To player, will seem like collision with background Wall objects placed at edge of black playfield. Show with dotted lines to represent being invisible during gameplay
Making Objects Invisible • Click on “visible” toggle • If no check, is invisible Make solid for bounce behavior
Place Objects in Room • Click on game room, then objects tab • Use pulldown menu to select object to place • Invisiblewalls • Bricks • Paddle • Ball
Ball Behavior • When ball is created, want it to start moving upwards at an angle • Use create event on ball • Start moving in direction • Click two up diagonal arrows • Speed of 10
Paddle Behavior - Movement • Left arrow moves left, right arrow moves right • Up/down arrows stop • Use keypress events for these
Paddle Behavior – Ball Collision • Ball should bounce after hitting paddle Drag-n-drop bounce to actions Pick collision event, then select ball from pull-down menu that appears
Wall Behavior • If paddle collides with wall, paddle stops • If ball collides with wall, want it to bounce • Could define this separately on all three wall types • Tedious • Error-prone, since every change needs to be copied over to the other two walls • Would be nice if this could be stated once, for all walls • Use object inheritance
Inheritance • Objects can have a parent • All of the behaviors of the parent are copied to its children • Imagine a “wall-mother” object • A collision event with the ball causes the ball to bounce • Now, make all three invisible walls have wall-mother as a parent • All invisible walls now collide with the ball like the mother! • By defining one wall-mother object, avoids cut-and-paste of collision behavior to three invisible walls. • Note that it is possible to change inherited behavior on children • Just define the specific event a different way. Child’s definition always trumps that of the parent.
Creating Wall-Mother Make ball bounce off walls No sprite, since we’re using this just for behavior. Leave it to children to specify exact visual shape. Don’t set visible, do set solid, since that’s what children should be. Visible doesn’t matter for wall-mother, since it has no sprite
Now, set parent of invisible walls Note no events or actions. It gets these all from its parent, wall-mother! Set parent to wall-mother using pull-down menu here
Brick behavior • If a ball hits a brick: • It should disappear • Small ring effect • Play sound • Ball should bounce • Score should go up • Three brick types • Use inheritance from new brick-mother • Put collisionbehavior on mother • Reuse on all bricks • Set each colored brick’s parent to “brick-mother”
Ball Bouncing Off Brick • The collision of brick with ball is on brick-mother • But, we want the ball to bounce, not the brick • How to do this? • Each collision is between two objects: • The object hosting the collision event • The “other” object • In this case, the brick is hosting the collision, the ball is the “other” • To indicate ball should bounce,select “other” in bouncedialog box
Making Brick Disappear • Each brick on screen is an instance of a brick object • Can think of the object as a kind of “mold” that can stamp out many different instances of the object • Brick object: mold :: individual bricks: instances • To make brick disappear: • Destroy the instance • On tabmain1
Creating Brick Ring Effect • On draw tab, select “Create Effect” button Add offset so ring emerges from center of the brick Click relative so ring emerges from brick, not upper left corner of screen!