Prototyping - Loose Ends & Final Thoughts
Our final part attacks some of the lingering issues:
- We kill some very evil memory leaks.
- We add more passable sprites and enhance the minimap by displaying desert sand.
- We stop the player ship from travelling to the edge of the map.
- Then I show how to implement night time and infrared in code although we won't bring it in to game play.
- Finally, I'll add the storyboards for both the briefing and debriefing through mission 5.
Final Thoughts
The code below is the end of the prototype. From this point forward, a developer could continue to add game features and maybe flesh out a new storyline or even a new episode. Eventually, you'll have to feature freeze the prototype and make an important decision: Continue to add the content to the prototype and release a final version using GameMaker. Or move to a custom, more lightweight, engine that implements exactly the features you need and go from there. Since this is a learning experience I highly recommend making this in a custom engine. I may decide to continue this educational project along those lines with C and SDL. We've designed entirely around the object concept, but I assure you that there is a sufficient design by going procedural. Do it!
GML Code
We won't need any new objects for these fixes so let's get right to the code
obj_map: Room End 1
Our map object doesn't automatically free large city background surface even though we call it in Destroy. We need to force destroy when the room ends.
1 2 |
///Ensure destruction instance_destroy() |
obj_map: Create 4
Add these two sprite indices to the case for passthrough
1 2 |
++ case $0F: ++ case $10: |
obj_hud: Draw Begin 1
We'll add a color for the new sand sprites to the minimap
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
///Create minimap if minimap_create { surface_set_target(minimap_surface) var xpos, ypos, img, tile; draw_set_alpha(1) for (ypos=0;ypos<201;ypos++) { for (xpos=0;xpos<201;xpos++) { var col; img = ds_grid_get(map.collision_map,xpos,ypos) tile = ds_grid_get(map.mapdata,xpos,ypos) if img = 0 then col=c_dkgray if img = 1 then col=c_ltgray if tile == $0F || tile == $10 then col = make_color_rgb(174,124,88) draw_sprite_ext(spr_debug,0,xpos,ypos,1,1,0,col,1) //draw_set_color(col) //draw_point(xpos,ypos) } } surface_reset_target() minimap_create = false } |
obj_ship: Step 6
Let's add an edge check to block the players ship from going all the way to the edge. We'll respond with a message. This is the whole event including the new changes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
///Collision Check var front_x = x+lengthdir_x(16,direction) var front_y = y+lengthdir_y(16,direction) var back_x = x+lengthdir_x(-16,direction) var back_y = y+lengthdir_y(-16,direction) if ds_grid_get(map.collision_map,map_pos(back_x),map_pos(back_y)) > 0 speed = abs(speed) if ds_grid_get(map.collision_map,map_pos(front_x),map_pos(front_y)) > 0 speed = -abs(speed) /* Edge barrier */ if is_player { if (map_pos(back_x) < 10 || map_pos(back_x) > 190 || map_pos(back_y) < 10 || map_pos(back_y) > 190) then { speed = abs(speed) hud.message = "Stay in your jurisdiction, velasquez" } if (map_pos(front_x) < 10 || map_pos(front_x) > 190 || map_pos(front_y) < 10 || map_pos(front_y) > 190) then { speed = -abs(speed) hud.message = "Stay in your jurisdiction, velasquez" } } |
obj_hud: Draw 1
This is an example of how we display the night time and infra-red effects using blend modes. This may not be possible in certain HTML5 implementations. In that case, we could pre-process all our graphics with 3 versions (normal, night, red) or we could introduce shaders
1 2 3 4 5 6 7 |
///Draw test night-time & infrared overlay draw_set_blend_mode_ext(bm_dest_color, bm_zero) draw_set_color(c_navy) draw_rectangle(view_xview[0],view_yview[0],view_xview[0]+view_wview[0]/2,view_yview[0]+view_hview[0],false) draw_set_color(c_red) draw_rectangle(view_xview[0]+view_wview[0]/2,view_yview[0],view_xview[0]+view_wview[0],view_yview[0]+view_hview[0],false) draw_set_blend_mode(bm_normal) |
obj_briefing: Create 5 (Briefing Storyboards)
This code block expands the briefing storyboards through mission 5. Beyond that, the briefing skips right to the gameplay. Note that the specific sprite names may different from your implementation depending on the order you've imported things in to GameMaker. I'm sure you know that already if you've made it this far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
///Briefing Flow if room == rm_brief { /* Default title only */ for (var i=1;i<60;i++) { brief[i,1] = BRIEFING.banner brief[i,2] = mission_title[i] brief[i,3] = BRIEFING.fin } brief[1,1] = BRIEFING.banner brief[1,2] = mission_title[1] brief[1,3] = BRIEFING.scr brief[1,4] = asset_get_index("sprite13_HANGAR") brief[1,5] = "upper hangar" brief[1,6] = "traffic department headquarters" brief[1,7] = "july 18 - 2192" brief[1,8] = BRIEFING.dialogue brief[1,9] = 0 brief[1,10] = BRIEFING.fin brief[2,1] = BRIEFING.banner brief[2,2] = mission_title[2] brief[2,3] = BRIEFING.scr brief[2,4] = asset_get_index("sprite38_TDLAB") brief[2,5] = "operations coordinator's office" brief[2,6] = "" brief[2,7] = "later..." brief[2,8] = BRIEFING.dialogue brief[2,9] = 3 brief[2,10] = BRIEFING.dialogue brief[2,11] = 4 brief[2,12] = BRIEFING.fin brief[3,1] = BRIEFING.banner brief[3,2] = mission_title[3] brief[3,3] = BRIEFING.scr brief[3,4] = asset_get_index("sprite13_HANGAR") brief[3,5] = "upper hangar" brief[3,6] = "traffic department headquarters" brief[3,7] = "next day" brief[3,8] = BRIEFING.dialogue brief[3,9] = 8 brief[3,10] = BRIEFING.fin brief[4,1] = BRIEFING.banner brief[4,2] = mission_title[4] brief[4,3] = BRIEFING.scr brief[4,4] = asset_get_index("sprite5_BRIEFING") brief[4,5] = "Td briefing auditorium" brief[4,6] = "that night" brief[4,7] = "" brief[4,8] = BRIEFING.dialogue brief[4,9] = 12 brief[4,10] = BRIEFING.scr brief[4,11] = asset_get_index("sprite13_HANGAR") brief[4,12] = "Upper Hanger" brief[4,13] = "Traffic Department Headquarters" brief[4,14] = "Later" brief[4,15] = BRIEFING.dialogue brief[4,16] = 13 brief[4,17] = BRIEFING.fin brief[5,1] = BRIEFING.banner brief[5,2] = mission_title[5] brief[5,3] = BRIEFING.scr brief[5,4] = asset_get_index("sprite40_VELSROOM") brief[5,5] = "Quarters of Lt. Velasquez" brief[5,6] = "where she sleeps uneasily" brief[5,7] = "" brief[5,8] = BRIEFING.dialogue brief[5,9] = 16 brief[5,10] = BRIEFING.scr brief[5,11] = asset_get_index("sprite37_SOFFICE") brief[5,12] = "commander satairs office" brief[5,13] = "traffic department headquarters" brief[5,14] = "5 radians later" brief[5,15] = BRIEFING.dialogue brief[5,16] = 17 brief[5,17] = BRIEFING.dialogue brief[5,18] = 18 brief[5,19] = BRIEFING.scr brief[5,20] = asset_get_index("sprite13_HANGAR") brief[5,21] = "Upper Hanger" brief[5,22] = "Traffic Department Headquarters" brief[5,23] = "Next Morning" brief[5,24] = BRIEFING.dialogue brief[5,25] = 19 brief[5,26] = BRIEFING.fin /* Insert more missions here */ } |
obj_briefing: Create 6 (Debriefing Storyboards)
And these are the debriefing storyboards through mission 5.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
///Debriefing storyboard if room == rm_debrief { /* Default None */ for (var i=1;i<60;i++) brief[i,1] = BRIEFING.fin brief[1, 1] = BRIEFING.scr brief[1, 2] = asset_get_index("sprite11_HANGAR") brief[1, 3] = "Upper hangar" brief[1, 4] = "Traffic Department Headquarters" brief[1, 5] = "5 radians later" brief[1, 6] = BRIEFING.dialogue brief[1, 7] = 1 brief[1, 8] = BRIEFING.scr brief[1, 9] = asset_get_index("sprite35_SOFFICE") brief[1, 10] = "command satairs office" brief[1, 11] = "traffic department headquarters" brief[1, 12] = "25 radians later" brief[1, 13] = BRIEFING.dialogue brief[1, 14] = 2 brief[1, 15] = BRIEFING.fin brief[2, 1] = BRIEFING.scr brief[2, 2] = asset_get_index("sprite11_HANGAR") brief[2, 3] = "Upper hangar" brief[2, 4] = "Traffic Department Headquarters" brief[2, 5] = "after mission" brief[2, 6] = BRIEFING.dialogue brief[2, 7] = 5 brief[2, 8] = BRIEFING.scr brief[2, 9] = asset_get_index("sprite35_SOFFICE") brief[2, 10] = "command satairs office" brief[2, 11] = "traffic department headquarters" brief[2, 12] = "5 radians later" brief[2, 13] = BRIEFING.dialogue brief[2, 14] = 6 brief[2, 15] = BRIEFING.scr brief[2, 16] = asset_get_index("sprite43_VOFFICE") brief[2, 17] = "colonel wolfencrofts office" brief[2, 18] = "vulture command institute" brief[2, 19] = "" brief[2, 20] = BRIEFING.dialogue brief[2, 21] = 7 brief[2, 22] = BRIEFING.fin brief[3, 1] = BRIEFING.scr brief[3, 2] = asset_get_index("sprite11_HANGAR") brief[3, 3] = "Upper hangar" brief[3, 4] = "Traffic Department Headquarters" brief[3, 5] = "after mission" brief[3, 6] = BRIEFING.dialogue brief[3, 7] = 10 brief[3, 8] = BRIEFING.scr brief[3, 9] = asset_get_index("sprite43_VOFFICE") brief[3, 10] = "colonel wolfencrofts office" brief[3, 11] = "vulture command institute" brief[3, 12] = "" brief[3, 13] = BRIEFING.dialogue brief[3, 14] = 11 brief[3, 15] = BRIEFING.fin brief[4, 1] = BRIEFING.scr brief[4, 2] = asset_get_index("sprite11_HANGAR") brief[4, 3] = "Upper hangar" brief[4, 4] = "Traffic Department Headquarters" brief[4, 5] = "after mission" brief[4, 6] = BRIEFING.dialogue brief[4, 7] = 14 brief[4, 8] = BRIEFING.scr brief[4, 9] = asset_get_index("sprite43_VOFFICE") brief[4, 10] = "colonel wolfencrofts office" brief[4, 11] = "vulture command institute" brief[4, 12] = "next morning" brief[4, 13] = BRIEFING.dialogue brief[4, 14] = 15 brief[4, 15] = BRIEFING.fin brief[5, 1] = BRIEFING.scr brief[5, 2] = asset_get_index("sprite11_HANGAR") brief[5, 3] = "Upper hangar" brief[5, 4] = "Traffic Department Headquarters" brief[5, 5] = "after mission" brief[5, 6] = BRIEFING.dialogue brief[5, 7] = 102 brief[5, 8] = BRIEFING.scr brief[5, 9] = asset_get_index("sprite43_VOFFICE") brief[5, 10] = "colonel wolfencrofts office" brief[5, 11] = "vulture command institute" brief[5, 12] = "" brief[5, 13] = BRIEFING.dialogue brief[5, 14] = 20 brief[5, 15] = BRIEFING.fin /* Add more debriefing storyboards here */ } |