diff options
Diffstat (limited to 'samples/99_genre_platformer')
6 files changed, 540 insertions, 117 deletions
diff --git a/samples/99_genre_platformer/clepto_frog/app/main.rb b/samples/99_genre_platformer/clepto_frog/app/main.rb index a4eb069..a3a237e 100644 --- a/samples/99_genre_platformer/clepto_frog/app/main.rb +++ b/samples/99_genre_platformer/clepto_frog/app/main.rb @@ -1,4 +1,4 @@ -MAP_FILE_PATH = 'app/map.txt' +MAP_FILE_PATH = 'map.txt' require 'app/map.rb' @@ -53,35 +53,7 @@ class CleptoFrog def render_intro outputs.labels << [640, 700, "Clepto Frog", 4, 1] - if state.tick_count >= 120 - outputs.labels << [640, 620, "\"Uh... your office has a pet frog?\" - New Guy", - 4, 1, 0, 0, 0, 255 * 120.ease(60)] - end - - if state.tick_count >= 240 - outputs.labels << [640, 580, "\"Yep! His name is Clepto.\" - Jim", - 4, 1, 0, 0, 0, 255 * 240.ease(60)] - end - - if state.tick_count >= 360 - outputs.labels << [640, 540, "\"Uh...\" - New Guy", - 4, 1, 0, 0, 0, 255 * 360.ease(60)] - end - - if state.tick_count >= 480 - outputs.labels << [640, 500, "\"He steals mugs while we're away...\" - Jim", - 4, 1, 0, 0, 0, 255 * 480.ease(60)] - end - - if state.tick_count >= 600 - outputs.labels << [640, 460, "\"It's not a big deal, we take them back in the morning.\" - Jim", - 4, 1, 0, 0, 0, 255 * 600.ease(60)] - end - - outputs.sprites << [640 - 50, 360 - 50, 100, 100, - "sprites/square-green.png"] - - if state.tick_count == 800 + if state.tick_count == 120 state.scene = :game state.game_start_at = state.tick_count end @@ -89,7 +61,7 @@ class CleptoFrog def tick defaults - if state.scene == :intro && state.tick_count <= 800 + if state.scene == :intro && state.tick_count <= 120 render_intro elsif state.scene == :ending render_ending @@ -192,15 +164,15 @@ class CleptoFrog if state.god_mode # SHOW HIDE COLLISIONS - outputs.sprites << state.world.map do |x, y, w, h| - x = vx(x) - y = vy(y) + outputs.sprites << state.world.map do |rect| + x = vx(rect.x) + y = vy(rect.y) if x > -80 && x < 1280 && y > -80 && y < 720 { x: x, y: y, - w: vw(w || state.tile_size), - h: vh(h || state.tile_size), + w: vw(rect.w || state.tile_size), + h: vh(rect.h || state.tile_size), path: 'sprites/square-gray.png', a: 128 } @@ -223,8 +195,10 @@ class CleptoFrog # Creates sprite following mouse to help indicate which sprite you have selected - outputs.primitives << [inputs.mouse.position.x, inputs.mouse.position.y, - state.tile_size, state.tile_size, 'sprites/square-indigo.png', 0, 100].sprite + outputs.primitives << [inputs.mouse.position.x - 32 * state.camera_scale, + inputs.mouse.position.y - 32 * state.camera_scale, + state.tile_size * state.camera_scale, + state.tile_size * state.camera_scale, 'sprites/square-indigo.png', 0, 100].sprite end render_mini_map @@ -305,6 +279,29 @@ class CleptoFrog set_camera_scale 1 end + if inputs.mouse.click + state.id_seed += 1 + id = state.id_seed + x = state.camera_x + (inputs.mouse.click.x.fdiv(state.camera_scale) - 32) + y = state.camera_y + (inputs.mouse.click.y.fdiv(state.camera_scale) - 32) + x = ((x + 2).idiv 4) * 4 + y = ((y + 2).idiv 4) * 4 + w = 64 + h = 64 + candidate_rect = { id: id, x: x, y: y, w: w, h: h } + scaled_candidate_rect = { x: x + 30, y: y + 30, w: w - 60, h: h - 60 } + to_remove = state.world.find { |r| r.intersect_rect? scaled_candidate_rect } + if to_remove && args.inputs.keyboard.x + state.world.reject! { |r| r.id == to_remove.id } + else + state.world << candidate_rect + end + export_map + state.world_lookup = {} + state.world_collision_rects = nil + calc_world_lookup + end + if input_up? state.y += 10 state.dy = 0 @@ -326,12 +323,6 @@ class CleptoFrog if state.scene == :game process_inputs_player_movement process_inputs_god_mode - elsif state.scene == :intro - if args.inputs.keyboard.key_down.enter || args.inputs.keyboard.key_down.space - if Kernel.tick_count < 600 - Kernel.tick_count = 600 - end - end end end @@ -429,17 +420,6 @@ class CleptoFrog end end - def add_floors - # floors - state.world += [ - [0, 0, 10000, 40], - [0, 1670, 3250, 60], - [6691, 1653, 3290, 60], - [1521, 3792, 7370, 60], - [0, 5137, 3290, 60] - ] - end - def attempt_load_world_from_file return if state.world # exported_world = gtk.read_file(MAP_FILE_PATH) @@ -447,26 +427,11 @@ class CleptoFrog state.objects = [] if $collisions - $collisions.map do |x, y, w, h| - state.world << [x, y, w, h] + state.id_seed ||= 0 + $collisions.each do |x, y, w, h| + state.id_seed += 1 + state.world << { id: state.id_seed, x: x, y: y, w: w, h: h } end - - add_floors - # elsif exported_world - # exported_world.each_line.map do |l| - # tokens = l.strip.split(',') - # x = tokens[0].to_i - # y = tokens[1].to_i - # type = tokens[2].to_i - # if type == 1 - # state.world << [x, y, state.tile_size, state.tile_size] - # elsif type == 2 - # w, h, path = tokens[3..-1] - # state.objects << [x, y, w.to_i, h.to_i, path] - # end - # end - - # add_floors end if $mugs @@ -487,23 +452,24 @@ class CleptoFrog # Searches through the world and finds the cordinates that exist state.world_lookup = {} - state.world.each do |x, y, w, h| - state.world_lookup[[x, y, w || state.tile_size, h || state.tile_size]] = true + state.world.each do |rect| + state.world_lookup[rect.id] = rect end # Assigns collision rects for every sprite drawn state.world_collision_rects = state.world_lookup .keys - .map do |x, y, w, h| + .map do |key| + rect = state.world_lookup[key] s = state.tile_size - w ||= s - h ||= s + rect.w ||= s + rect.h ||= s { - args: [x, y, w, h], - left_right: [x, y + 4, w, h - 6], - top: [x + 4, y + 6, w - 8, h - 6], - bottom: [x + 1, y - 1, w - 2, h - 8], + args: rect, + left_right: { x: rect.x, y: rect.y + 4, w: rect.w, h: rect.h - 6 }, + top: { x: rect.x + 4, y: rect.y + 6, w: rect.w - 8, h: rect.h - 6 }, + bottom: { x: rect.x + 1, y: rect.y - 1, w: rect.w - 2, h: rect.h - 8 }, } end @@ -559,12 +525,21 @@ class CleptoFrog def end_of_tongue p = state.tongue_angle.vector(state.tongue_length) - [start_of_tongue.x + p.x, start_of_tongue.y + p.y] + { x: start_of_tongue.x + p.x, y: start_of_tongue.y + p.y } end def calc_shooting + calc_shooting_increment + calc_shooting_increment + calc_shooting_increment + calc_shooting_increment + calc_shooting_increment + calc_shooting_increment + end + + def calc_shooting_increment return unless state.action == :shooting - state.tongue_length += 30 + state.tongue_length += 5 potential_anchor = end_of_tongue if potential_anchor.x <= 0 state.anchor_point = potential_anchor @@ -583,9 +558,9 @@ class CleptoFrog state.action = :anchored outputs.sounds << 'sounds/attached.wav' else - anchor_rect = [potential_anchor.x - 5, potential_anchor.y - 5, 10, 10] + anchor_rect = { x: potential_anchor.x - 5, y: potential_anchor.y - 5, w: 10, h: 10 } collision = state.world_collision_rects.find_all do |v| - [v[:args].x, v[:args].y, v[:args].w, v[:args].h].intersect_rect?(anchor_rect) + v[:args].intersect_rect?(anchor_rect) end.first if collision state.anchor_point = potential_anchor @@ -681,7 +656,7 @@ class CleptoFrog .first return unless left_side_collisions - state.x = left_side_collisions[:left_right].right + state.x = left_side_collisions[:left_right].right + 1 state.dx = state.dy.abs * 0.8 state.collision_on_x = true end @@ -696,7 +671,7 @@ class CleptoFrog .first return unless right_side_collisions - state.x = right_side_collisions[:left_right].left - state.tile_size + state.x = right_side_collisions[:left_right].left - state.tile_size - 1 state.dx = state.dx.abs * 0.8 * -1 state.collision_on_x = true end @@ -712,7 +687,7 @@ class CleptoFrog .first return unless ceil_collisions - state.y = ceil_collisions[:bottom].y - state.tile_size + state.y = ceil_collisions[:bottom].y - state.tile_size - 1 state.dy = state.dy.abs * 0.8 * -1 state.collision_on_y = true end @@ -725,13 +700,17 @@ class CleptoFrog end def export_map - export_string = state.world.map do |x, y| - "#{x},#{y},1" - end + export_string = "$collisions = [\n" + export_string += state.world.map do |rect| + "[#{rect.x},#{rect.y},#{rect.w},#{rect.h}]," + end.join "\n" + export_string += "\n]\n\n" + export_string += "$mugs = [\n" export_string += state.objects.map do |x, y, w, h, path| - "#{x},#{y},2,#{w},#{h},#{path}" - end - gtk.write_file(MAP_FILE_PATH, export_string.join("\n")) + "[#{x},#{y},#{w},#{h},'#{path}']," + end.join "\n" + export_string += "\n]\n\n" + gtk.write_file(MAP_FILE_PATH, export_string) state.map_saved_at = state.tick_count end diff --git a/samples/99_genre_platformer/clepto_frog/app/map.rb b/samples/99_genre_platformer/clepto_frog/app/map.rb index c048c82..a504ff9 100644 --- a/samples/99_genre_platformer/clepto_frog/app/map.rb +++ b/samples/99_genre_platformer/clepto_frog/app/map.rb @@ -989,6 +989,11 @@ $collisions = [ [4459, 3997, 64, 64], [76, 5215, 64, 64], [39, 5217, 64, 64], + [0, 0, 10000, 40], + [0, 1670, 3250, 60], + [6691, 1653, 3290, 60], + [1521, 3792, 7370, 60], + [0, 5137, 3290, 60] ] $mugs = [ diff --git a/samples/99_genre_platformer/clepto_frog/replay.txt b/samples/99_genre_platformer/clepto_frog/replay.txt new file mode 100644 index 0000000..8662d31 --- /dev/null +++ b/samples/99_genre_platformer/clepto_frog/replay.txt @@ -0,0 +1,249 @@ +replay_version 2.0 +stopped_at 1097 +seed 100 +recorded_at 2021-11-20 11:32:38 -0600 +[:mouse_button_up, 1, 0, 1, 1, 4] +[:key_down_raw, 1073741903, 0, 2, 2, 157] +[:key_down_raw, 1073741903, 0, 2, 3, 171] +[:key_down_raw, 1073741903, 0, 2, 4, 174] +[:key_down_raw, 1073741903, 0, 2, 5, 176] +[:key_down_raw, 1073741903, 0, 2, 6, 177] +[:key_down_raw, 1073741903, 0, 2, 7, 179] +[:key_down_raw, 1073741903, 0, 2, 8, 181] +[:key_down_raw, 1073741903, 0, 2, 9, 182] +[:key_down_raw, 1073741903, 0, 2, 10, 185] +[:key_up_raw, 1073741903, 0, 2, 11, 185] +[:key_down_raw, 32, 0, 2, 12, 187] +[:key_up_raw, 32, 0, 2, 13, 190] +[:key_down_raw, 1073741906, 0, 2, 14, 231] +[:key_down_raw, 1073741903, 0, 2, 15, 239] +[:key_down_raw, 1073741903, 0, 2, 16, 252] +[:key_down_raw, 1073741903, 0, 2, 17, 254] +[:key_down_raw, 1073741903, 0, 2, 18, 256] +[:key_down_raw, 1073741903, 0, 2, 19, 258] +[:key_down_raw, 1073741903, 0, 2, 20, 259] +[:key_down_raw, 1073741903, 0, 2, 21, 261] +[:key_down_raw, 1073741903, 0, 2, 22, 263] +[:key_down_raw, 1073741903, 0, 2, 23, 265] +[:key_down_raw, 1073741903, 0, 2, 24, 267] +[:key_down_raw, 1073741903, 0, 2, 25, 269] +[:key_down_raw, 1073741903, 0, 2, 26, 271] +[:key_down_raw, 1073741903, 0, 2, 27, 273] +[:key_down_raw, 1073741903, 0, 2, 28, 274] +[:key_down_raw, 1073741903, 0, 2, 29, 276] +[:key_down_raw, 1073741903, 0, 2, 30, 278] +[:key_down_raw, 1073741903, 0, 2, 31, 280] +[:key_down_raw, 1073741903, 0, 2, 32, 282] +[:key_down_raw, 1073741903, 0, 2, 33, 284] +[:key_down_raw, 1073741903, 0, 2, 34, 286] +[:key_down_raw, 1073741903, 0, 2, 35, 287] +[:key_down_raw, 1073741903, 0, 2, 36, 289] +[:key_down_raw, 1073741903, 0, 2, 37, 291] +[:key_down_raw, 1073741903, 0, 2, 38, 293] +[:key_down_raw, 1073741903, 0, 2, 39, 295] +[:key_down_raw, 1073741903, 0, 2, 40, 296] +[:key_down_raw, 1073741903, 0, 2, 41, 298] +[:key_down_raw, 1073741903, 0, 2, 42, 300] +[:key_down_raw, 1073741903, 0, 2, 43, 302] +[:key_down_raw, 1073741903, 0, 2, 44, 303] +[:key_down_raw, 1073741903, 0, 2, 45, 305] +[:key_down_raw, 1073741903, 0, 2, 46, 307] +[:key_down_raw, 1073741903, 0, 2, 47, 309] +[:key_down_raw, 1073741903, 0, 2, 48, 310] +[:key_down_raw, 1073741903, 0, 2, 49, 312] +[:key_down_raw, 1073741903, 0, 2, 50, 314] +[:key_down_raw, 1073741903, 0, 2, 51, 316] +[:key_down_raw, 1073741903, 0, 2, 52, 318] +[:key_down_raw, 1073741903, 0, 2, 53, 320] +[:key_down_raw, 1073741903, 0, 2, 54, 322] +[:key_down_raw, 1073741903, 0, 2, 55, 324] +[:key_down_raw, 1073741903, 0, 2, 56, 326] +[:key_down_raw, 1073741903, 0, 2, 57, 328] +[:key_down_raw, 1073741903, 0, 2, 58, 330] +[:key_down_raw, 1073741903, 0, 2, 59, 332] +[:key_down_raw, 1073741903, 0, 2, 60, 334] +[:key_down_raw, 1073741903, 0, 2, 61, 336] +[:key_down_raw, 1073741903, 0, 2, 62, 338] +[:key_down_raw, 1073741903, 0, 2, 63, 340] +[:key_down_raw, 1073741903, 0, 2, 64, 342] +[:key_down_raw, 1073741903, 0, 2, 65, 344] +[:key_down_raw, 1073741903, 0, 2, 66, 345] +[:key_down_raw, 1073741903, 0, 2, 67, 347] +[:key_down_raw, 1073741903, 0, 2, 68, 349] +[:key_up_raw, 1073741906, 0, 2, 69, 351] +[:key_down_raw, 1073741903, 0, 2, 70, 351] +[:key_down_raw, 1073741903, 0, 2, 71, 353] +[:key_down_raw, 1073741903, 0, 2, 72, 355] +[:key_down_raw, 1073741903, 0, 2, 73, 357] +[:key_down_raw, 1073741903, 0, 2, 74, 359] +[:key_down_raw, 1073741903, 0, 2, 75, 361] +[:key_down_raw, 1073741903, 0, 2, 76, 363] +[:key_down_raw, 1073741903, 0, 2, 77, 365] +[:key_down_raw, 1073741903, 0, 2, 78, 367] +[:key_down_raw, 1073741903, 0, 2, 79, 369] +[:key_down_raw, 1073741903, 0, 2, 80, 371] +[:key_down_raw, 1073741903, 0, 2, 81, 373] +[:key_down_raw, 1073741903, 0, 2, 82, 375] +[:key_down_raw, 1073741903, 0, 2, 83, 376] +[:key_down_raw, 1073741903, 0, 2, 84, 378] +[:key_down_raw, 1073741903, 0, 2, 85, 380] +[:key_down_raw, 1073741903, 0, 2, 86, 382] +[:key_down_raw, 1073741903, 0, 2, 87, 384] +[:key_down_raw, 1073741903, 0, 2, 88, 386] +[:key_down_raw, 1073741906, 0, 2, 89, 386] +[:key_down_raw, 1073741906, 0, 2, 90, 400] +[:key_down_raw, 1073741906, 0, 2, 91, 402] +[:key_down_raw, 1073741906, 0, 2, 92, 404] +[:key_down_raw, 1073741906, 0, 2, 93, 405] +[:key_down_raw, 1073741906, 0, 2, 94, 407] +[:key_down_raw, 1073741906, 0, 2, 95, 409] +[:key_down_raw, 1073741906, 0, 2, 96, 411] +[:key_down_raw, 1073741906, 0, 2, 97, 413] +[:key_down_raw, 1073741906, 0, 2, 98, 415] +[:key_down_raw, 1073741906, 0, 2, 99, 417] +[:key_down_raw, 1073741906, 0, 2, 100, 419] +[:key_down_raw, 1073741906, 0, 2, 101, 421] +[:key_down_raw, 1073741906, 0, 2, 102, 422] +[:key_down_raw, 1073741906, 0, 2, 103, 424] +[:key_down_raw, 1073741906, 0, 2, 104, 426] +[:key_down_raw, 1073741906, 0, 2, 105, 428] +[:key_down_raw, 1073741906, 0, 2, 106, 430] +[:key_down_raw, 1073741906, 0, 2, 107, 432] +[:key_down_raw, 1073741906, 0, 2, 108, 434] +[:key_down_raw, 32, 0, 2, 109, 434] +[:key_up_raw, 32, 0, 2, 110, 442] +[:key_up_raw, 1073741906, 0, 2, 111, 460] +[:key_up_raw, 1073741903, 0, 2, 112, 576] +[:key_down_raw, 1073741903, 0, 2, 113, 588] +[:key_down_raw, 1073741903, 0, 2, 114, 602] +[:key_down_raw, 1073741903, 0, 2, 115, 604] +[:key_down_raw, 1073741903, 0, 2, 116, 606] +[:key_down_raw, 1073741903, 0, 2, 117, 608] +[:key_down_raw, 1073741903, 0, 2, 118, 610] +[:key_down_raw, 1073741903, 0, 2, 119, 612] +[:key_down_raw, 1073741903, 0, 2, 120, 614] +[:key_down_raw, 1073741903, 0, 2, 121, 616] +[:key_down_raw, 1073741903, 0, 2, 122, 617] +[:key_down_raw, 1073741903, 0, 2, 123, 619] +[:key_down_raw, 1073741903, 0, 2, 124, 621] +[:key_down_raw, 1073741903, 0, 2, 125, 623] +[:key_down_raw, 1073741903, 0, 2, 126, 624] +[:key_down_raw, 1073741903, 0, 2, 127, 626] +[:key_down_raw, 1073741903, 0, 2, 128, 628] +[:key_down_raw, 1073741903, 0, 2, 129, 630] +[:key_down_raw, 1073741903, 0, 2, 130, 632] +[:key_down_raw, 1073741903, 0, 2, 131, 634] +[:key_down_raw, 1073741903, 0, 2, 132, 636] +[:key_down_raw, 1073741903, 0, 2, 133, 638] +[:key_down_raw, 1073741903, 0, 2, 134, 640] +[:key_down_raw, 1073741903, 0, 2, 135, 641] +[:key_down_raw, 1073741903, 0, 2, 136, 643] +[:key_down_raw, 1073741903, 0, 2, 137, 645] +[:key_down_raw, 1073741903, 0, 2, 138, 647] +[:key_down_raw, 1073741903, 0, 2, 139, 649] +[:key_down_raw, 1073741903, 0, 2, 140, 651] +[:key_down_raw, 1073741903, 0, 2, 141, 653] +[:key_down_raw, 1073741903, 0, 2, 142, 655] +[:key_down_raw, 1073741903, 0, 2, 143, 656] +[:key_down_raw, 1073741903, 0, 2, 144, 658] +[:key_down_raw, 1073741903, 0, 2, 145, 660] +[:key_down_raw, 1073741903, 0, 2, 146, 662] +[:key_down_raw, 1073741903, 0, 2, 147, 664] +[:key_down_raw, 1073741903, 0, 2, 148, 666] +[:key_down_raw, 1073741903, 0, 2, 149, 668] +[:key_down_raw, 1073741903, 0, 2, 150, 670] +[:key_down_raw, 1073741903, 0, 2, 151, 672] +[:key_down_raw, 1073741903, 0, 2, 152, 674] +[:key_down_raw, 1073741903, 0, 2, 153, 676] +[:key_down_raw, 1073741903, 0, 2, 154, 678] +[:key_down_raw, 1073741903, 0, 2, 155, 680] +[:key_down_raw, 1073741903, 0, 2, 156, 681] +[:key_down_raw, 1073741903, 0, 2, 157, 683] +[:key_down_raw, 32, 0, 2, 158, 684] +[:key_up_raw, 1073741903, 0, 2, 159, 686] +[:key_up_raw, 32, 0, 2, 160, 689] +[:key_down_raw, 1073741904, 0, 2, 161, 692] +[:key_down_raw, 1073741904, 0, 2, 162, 704] +[:key_down_raw, 1073741904, 0, 2, 163, 706] +[:key_down_raw, 1073741904, 0, 2, 164, 707] +[:key_down_raw, 1073741904, 0, 2, 165, 709] +[:key_down_raw, 1073741904, 0, 2, 166, 711] +[:key_down_raw, 1073741904, 0, 2, 167, 713] +[:key_down_raw, 1073741904, 0, 2, 168, 715] +[:key_up_raw, 1073741904, 0, 2, 169, 717] +[:key_down_raw, 32, 0, 2, 170, 769] +[:key_up_raw, 32, 0, 2, 171, 775] +[:key_down_raw, 1073741904, 0, 2, 172, 785] +[:key_down_raw, 1073741904, 0, 2, 173, 799] +[:key_down_raw, 1073741904, 0, 2, 174, 801] +[:key_down_raw, 1073741904, 0, 2, 175, 803] +[:key_down_raw, 1073741904, 0, 2, 176, 805] +[:key_down_raw, 1073741904, 0, 2, 177, 807] +[:key_down_raw, 1073741904, 0, 2, 178, 810] +[:key_down_raw, 1073741904, 0, 2, 179, 812] +[:key_down_raw, 1073741904, 0, 2, 180, 814] +[:key_down_raw, 1073741904, 0, 2, 181, 816] +[:key_down_raw, 1073741904, 0, 2, 182, 818] +[:key_down_raw, 1073741904, 0, 2, 183, 820] +[:key_down_raw, 1073741904, 0, 2, 184, 822] +[:key_down_raw, 1073741904, 0, 2, 185, 824] +[:key_down_raw, 1073741904, 0, 2, 186, 826] +[:key_down_raw, 1073741904, 0, 2, 187, 828] +[:key_down_raw, 1073741904, 0, 2, 188, 830] +[:key_down_raw, 1073741904, 0, 2, 189, 832] +[:key_down_raw, 1073741904, 0, 2, 190, 834] +[:key_down_raw, 1073741904, 0, 2, 191, 836] +[:key_down_raw, 1073741904, 0, 2, 192, 838] +[:key_down_raw, 1073741904, 0, 2, 193, 840] +[:key_down_raw, 1073741904, 0, 2, 194, 841] +[:key_down_raw, 1073741904, 0, 2, 195, 843] +[:key_down_raw, 1073741904, 0, 2, 196, 845] +[:key_down_raw, 1073741904, 0, 2, 197, 847] +[:key_down_raw, 1073741904, 0, 2, 198, 849] +[:key_down_raw, 1073741904, 0, 2, 199, 851] +[:key_down_raw, 1073741904, 0, 2, 200, 853] +[:key_down_raw, 1073741904, 0, 2, 201, 855] +[:key_down_raw, 1073741904, 0, 2, 202, 857] +[:key_down_raw, 1073741904, 0, 2, 203, 859] +[:key_down_raw, 1073741904, 0, 2, 204, 861] +[:key_down_raw, 1073741904, 0, 2, 205, 863] +[:key_down_raw, 1073741904, 0, 2, 206, 864] +[:key_down_raw, 1073741904, 0, 2, 207, 866] +[:key_down_raw, 1073741904, 0, 2, 208, 868] +[:key_down_raw, 1073741904, 0, 2, 209, 870] +[:key_down_raw, 1073741904, 0, 2, 210, 872] +[:key_down_raw, 1073741904, 0, 2, 211, 874] +[:key_down_raw, 1073741904, 0, 2, 212, 876] +[:key_down_raw, 1073741904, 0, 2, 213, 878] +[:key_down_raw, 1073741904, 0, 2, 214, 880] +[:key_down_raw, 1073741904, 0, 2, 215, 882] +[:key_down_raw, 1073741904, 0, 2, 216, 884] +[:key_down_raw, 1073741904, 0, 2, 217, 886] +[:key_down_raw, 1073741904, 0, 2, 218, 887] +[:key_down_raw, 1073741904, 0, 2, 219, 889] +[:key_down_raw, 1073741904, 0, 2, 220, 891] +[:key_down_raw, 1073741904, 0, 2, 221, 893] +[:key_down_raw, 1073741904, 0, 2, 222, 895] +[:key_down_raw, 1073741904, 0, 2, 223, 897] +[:key_down_raw, 1073741904, 0, 2, 224, 899] +[:key_down_raw, 1073741904, 0, 2, 225, 901] +[:key_down_raw, 1073741904, 0, 2, 226, 903] +[:key_down_raw, 1073741904, 0, 2, 227, 905] +[:key_down_raw, 1073741904, 0, 2, 228, 907] +[:key_down_raw, 1073741904, 0, 2, 229, 909] +[:key_down_raw, 1073741904, 0, 2, 230, 911] +[:key_down_raw, 1073741904, 0, 2, 231, 913] +[:key_down_raw, 1073741904, 0, 2, 232, 915] +[:key_down_raw, 1073741904, 0, 2, 233, 917] +[:key_down_raw, 1073741904, 0, 2, 234, 919] +[:key_down_raw, 1073741904, 0, 2, 235, 921] +[:key_down_raw, 1073741904, 0, 2, 236, 923] +[:key_down_raw, 1073741904, 0, 2, 237, 925] +[:key_down_raw, 1073741904, 0, 2, 238, 927] +[:key_down_raw, 1073741904, 0, 2, 239, 929] +[:key_up_raw, 1073741904, 0, 2, 240, 930] +[:key_down_raw, 1073741904, 0, 2, 241, 1024] +[:key_up_raw, 1073741904, 0, 2, 242, 1036] +[:key_down_raw, 96, 0, 2, 243, 1046] +[:key_up_raw, 96, 0, 2, 244, 1050] +[:key_down_raw, 13, 0, 2, 245, 1097] diff --git a/samples/99_genre_platformer/gorillas_basic/app/repl.rb b/samples/99_genre_platformer/gorillas_basic/app/repl.rb deleted file mode 100644 index 4428c4b..0000000 --- a/samples/99_genre_platformer/gorillas_basic/app/repl.rb +++ /dev/null @@ -1,17 +0,0 @@ -begin - if $gtk.args.state.current_turn == :player_1_angle - $gtk.args.state.player_1_angle = "#{60 + 10.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - $gtk.args.state.player_1_velocity = "#{30 + 20.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - elsif $gtk.args.state.current_turn == :player_2_angle - $gtk.args.state.player_2_angle = "#{60 + 10.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - $gtk.args.state.player_2_velocity = "#{30 + 20.randomize(:ratio).to_i}" - $you_so_basic_gorillas.input_execute_turn - else - $you_so_basic_gorillas.input_execute_turn - end -rescue Exception => e - puts e -end diff --git a/samples/99_genre_platformer/the_little_probe/app/main.rb b/samples/99_genre_platformer/the_little_probe/app/main.rb index 8fcf279..9d43ce6 100644 --- a/samples/99_genre_platformer/the_little_probe/app/main.rb +++ b/samples/99_genre_platformer/the_little_probe/app/main.rb @@ -394,6 +394,7 @@ class FallingCircle end def load_lines file + return unless state.snaps data = gtk.read_file(file) || "" data.each_line .reject { |l| l.strip.length == 0 } @@ -452,10 +453,10 @@ class FallingCircle results[:point] = { x: x, y: y } results[:rect] = { x: x - radius, y: y - radius, w: radius * 2, h: radius * 2 } results[:trajectory] = trajectory(results) - results[:impacts] = terrain.find_all { |t| line_near_rect? results[:rect], t }.map do |t| + results[:impacts] = terrain.find_all { |t| t && (line_near_rect? results[:rect], t) }.map do |t| { terrain: t, - point: geometry.line_intersect(results[:trajectory], t), + point: geometry.line_intersect(results[:trajectory], t, replace_infinity: 1000), type: :terrain } end.reject { |t| !point_within_line? t[:point], t[:terrain] } @@ -463,10 +464,10 @@ class FallingCircle results[:impacts] += lava.find_all { |t| line_near_rect? results[:rect], t }.map do |t| { terrain: t, - point: geometry.line_intersect(results[:trajectory], t), + point: geometry.line_intersect(results[:trajectory], t, replace_infinity: 1000), type: :lava } - end.reject { |t| !point_within_line? t[:point], t[:terrain] } + end.reject { |t| !t || (!point_within_line? t[:point], t[:terrain]) } results end @@ -479,6 +480,7 @@ class FallingCircle end def calc_terrains_to_monitor + return unless circle.impacts circle.impact = nil circle.impacts.each do |i| circle.terrains_to_monitor[i[:terrain]] ||= { diff --git a/samples/99_genre_platformer/the_little_probe/bug-replay.txt b/samples/99_genre_platformer/the_little_probe/bug-replay.txt new file mode 100644 index 0000000..378d3c3 --- /dev/null +++ b/samples/99_genre_platformer/the_little_probe/bug-replay.txt @@ -0,0 +1,205 @@ +replay_version 2.0 +stopped_at 2085 +seed 100 +recorded_at 2021-11-20 11:34:07 -0600 +[:mouse_button_up, 1, 0, 1, 1, 1] +[:mouse_move, 803, 93, 2, 2, 31] +[:mouse_move, 811, 93, 2, 3, 32] +[:key_down_raw, 1073741903, 0, 2, 4, 123] +[:key_down_raw, 1073741903, 0, 2, 5, 137] +[:key_down_raw, 1073741903, 0, 2, 6, 139] +[:key_down_raw, 1073741903, 0, 2, 7, 141] +[:key_down_raw, 1073741903, 0, 2, 8, 143] +[:key_down_raw, 1073741903, 0, 2, 9, 145] +[:key_down_raw, 1073741903, 0, 2, 10, 147] +[:key_down_raw, 1073741903, 0, 2, 11, 149] +[:key_up_raw, 1073741903, 0, 2, 12, 150] +[:key_down_raw, 32, 0, 2, 13, 171] +[:key_down_raw, 32, 0, 2, 14, 186] +[:key_down_raw, 32, 0, 2, 15, 189] +[:key_down_raw, 32, 0, 2, 16, 190] +[:key_down_raw, 32, 0, 2, 17, 192] +[:key_down_raw, 32, 0, 2, 18, 194] +[:key_down_raw, 32, 0, 2, 19, 196] +[:key_down_raw, 32, 0, 2, 20, 198] +[:key_down_raw, 32, 0, 2, 21, 200] +[:key_down_raw, 32, 0, 2, 22, 202] +[:key_down_raw, 32, 0, 2, 23, 204] +[:key_down_raw, 32, 0, 2, 24, 206] +[:key_down_raw, 32, 0, 2, 25, 208] +[:key_down_raw, 32, 0, 2, 26, 210] +[:key_down_raw, 32, 0, 2, 27, 212] +[:key_down_raw, 32, 0, 2, 28, 214] +[:key_down_raw, 32, 0, 2, 29, 216] +[:key_down_raw, 32, 0, 2, 30, 218] +[:key_down_raw, 32, 0, 2, 31, 221] +[:key_down_raw, 32, 0, 2, 32, 222] +[:key_down_raw, 32, 0, 2, 33, 224] +[:key_down_raw, 32, 0, 2, 34, 227] +[:key_down_raw, 32, 0, 2, 35, 229] +[:key_down_raw, 32, 0, 2, 36, 231] +[:key_down_raw, 32, 0, 2, 37, 233] +[:key_down_raw, 32, 0, 2, 38, 235] +[:key_down_raw, 32, 0, 2, 39, 237] +[:key_down_raw, 32, 0, 2, 40, 239] +[:key_down_raw, 32, 0, 2, 41, 241] +[:key_down_raw, 32, 0, 2, 42, 243] +[:key_down_raw, 32, 0, 2, 43, 245] +[:key_down_raw, 32, 0, 2, 44, 247] +[:key_down_raw, 32, 0, 2, 45, 249] +[:key_down_raw, 32, 0, 2, 46, 251] +[:key_down_raw, 32, 0, 2, 47, 253] +[:key_down_raw, 32, 0, 2, 48, 255] +[:key_down_raw, 32, 0, 2, 49, 257] +[:key_down_raw, 32, 0, 2, 50, 259] +[:key_down_raw, 32, 0, 2, 51, 261] +[:key_down_raw, 32, 0, 2, 52, 263] +[:key_down_raw, 32, 0, 2, 53, 265] +[:key_down_raw, 32, 0, 2, 54, 267] +[:key_down_raw, 32, 0, 2, 55, 269] +[:key_down_raw, 32, 0, 2, 56, 271] +[:key_down_raw, 1073741903, 0, 2, 57, 272] +[:key_up_raw, 1073741903, 0, 2, 58, 284] +[:key_up_raw, 32, 0, 2, 59, 350] +[:key_down_raw, 1073741904, 0, 2, 60, 611] +[:key_down_raw, 1073741904, 0, 2, 61, 626] +[:key_down_raw, 1073741904, 0, 2, 62, 628] +[:key_down_raw, 1073741904, 0, 2, 63, 630] +[:key_down_raw, 1073741904, 0, 2, 64, 632] +[:key_down_raw, 1073741904, 0, 2, 65, 634] +[:key_down_raw, 1073741904, 0, 2, 66, 636] +[:key_up_raw, 1073741904, 0, 2, 67, 636] +[:key_down_raw, 32, 0, 2, 68, 640] +[:key_down_raw, 32, 0, 2, 69, 655] +[:key_down_raw, 32, 0, 2, 70, 657] +[:key_down_raw, 32, 0, 2, 71, 659] +[:key_down_raw, 32, 0, 2, 72, 661] +[:key_down_raw, 32, 0, 2, 73, 663] +[:key_down_raw, 32, 0, 2, 74, 665] +[:key_down_raw, 1073741903, 0, 2, 75, 666] +[:key_up_raw, 1073741903, 0, 2, 76, 672] +[:key_down_raw, 1073741903, 0, 2, 77, 703] +[:key_down_raw, 1073741903, 0, 2, 78, 717] +[:key_up_raw, 1073741903, 0, 2, 79, 717] +[:key_down_raw, 1073741903, 0, 2, 80, 736] +[:key_up_raw, 1073741903, 0, 2, 81, 741] +[:key_up_raw, 32, 0, 2, 82, 798] +[:key_down_raw, 1073741903, 0, 2, 83, 861] +[:key_down_raw, 1073741903, 0, 2, 84, 876] +[:key_down_raw, 1073741903, 0, 2, 85, 878] +[:key_down_raw, 1073741903, 0, 2, 86, 880] +[:key_down_raw, 1073741903, 0, 2, 87, 882] +[:key_down_raw, 1073741903, 0, 2, 88, 884] +[:key_up_raw, 1073741903, 0, 2, 89, 886] +[:key_down_raw, 1073741903, 0, 2, 90, 1063] +[:key_down_raw, 1073741903, 0, 2, 91, 1079] +[:key_down_raw, 1073741903, 0, 2, 92, 1081] +[:key_down_raw, 1073741903, 0, 2, 93, 1083] +[:key_down_raw, 1073741903, 0, 2, 94, 1085] +[:key_down_raw, 1073741903, 0, 2, 95, 1086] +[:key_down_raw, 1073741903, 0, 2, 96, 1088] +[:key_down_raw, 1073741903, 0, 2, 97, 1090] +[:key_down_raw, 1073741903, 0, 2, 98, 1092] +[:key_down_raw, 1073741903, 0, 2, 99, 1094] +[:key_down_raw, 1073741903, 0, 2, 100, 1096] +[:key_down_raw, 1073741903, 0, 2, 101, 1098] +[:key_down_raw, 1073741903, 0, 2, 102, 1100] +[:key_down_raw, 1073741903, 0, 2, 103, 1102] +[:key_down_raw, 1073741903, 0, 2, 104, 1104] +[:key_down_raw, 1073741903, 0, 2, 105, 1106] +[:key_down_raw, 1073741903, 0, 2, 106, 1109] +[:key_down_raw, 1073741903, 0, 2, 107, 1111] +[:key_down_raw, 1073741903, 0, 2, 108, 1113] +[:key_down_raw, 1073741903, 0, 2, 109, 1115] +[:key_down_raw, 1073741903, 0, 2, 110, 1117] +[:key_down_raw, 1073741903, 0, 2, 111, 1119] +[:key_down_raw, 1073741903, 0, 2, 112, 1121] +[:key_down_raw, 1073741903, 0, 2, 113, 1122] +[:key_down_raw, 1073741903, 0, 2, 114, 1125] +[:key_down_raw, 1073741903, 0, 2, 115, 1127] +[:key_down_raw, 1073741903, 0, 2, 116, 1128] +[:key_down_raw, 1073741903, 0, 2, 117, 1131] +[:key_down_raw, 1073741903, 0, 2, 118, 1132] +[:key_down_raw, 1073741903, 0, 2, 119, 1134] +[:key_down_raw, 1073741903, 0, 2, 120, 1136] +[:key_down_raw, 1073741903, 0, 2, 121, 1138] +[:key_down_raw, 1073741903, 0, 2, 122, 1140] +[:key_down_raw, 1073741903, 0, 2, 123, 1142] +[:key_up_raw, 1073741903, 0, 2, 124, 1142] +[:key_down_raw, 32, 0, 2, 125, 1208] +[:key_down_raw, 32, 0, 2, 126, 1223] +[:key_down_raw, 32, 0, 2, 127, 1225] +[:key_down_raw, 1073741903, 0, 2, 128, 1226] +[:key_up_raw, 1073741903, 0, 2, 129, 1236] +[:key_down_raw, 1073741904, 0, 2, 130, 1253] +[:key_up_raw, 1073741904, 0, 2, 131, 1266] +[:key_down_raw, 1073741903, 0, 2, 132, 1324] +[:key_up_raw, 1073741903, 0, 2, 133, 1330] +[:key_down_raw, 1073741903, 0, 2, 134, 1414] +[:key_up_raw, 1073741903, 0, 2, 135, 1417] +[:key_up_raw, 32, 0, 2, 136, 1441] +[:mouse_move, 812, 92, 2, 137, 1607] +[:mouse_move, 818, 92, 2, 138, 1608] +[:mouse_move, 818, 91, 2, 139, 1614] +[:mouse_move, 818, 90, 2, 140, 1622] +[:mouse_move, 813, 89, 2, 141, 1623] +[:mouse_move, 801, 86, 2, 142, 1624] +[:mouse_move, 786, 83, 2, 143, 1625] +[:mouse_move, 770, 82, 2, 144, 1626] +[:mouse_move, 756, 82, 2, 145, 1627] +[:mouse_move, 745, 82, 2, 146, 1628] +[:mouse_move, 738, 82, 2, 147, 1629] +[:mouse_move, 731, 83, 2, 148, 1630] +[:mouse_move, 724, 84, 2, 149, 1631] +[:mouse_move, 712, 85, 2, 150, 1632] +[:mouse_move, 707, 87, 2, 151, 1633] +[:mouse_move, 702, 89, 2, 152, 1634] +[:mouse_move, 699, 95, 2, 153, 1635] +[:mouse_move, 693, 102, 2, 154, 1636] +[:mouse_move, 687, 110, 2, 155, 1637] +[:mouse_move, 680, 118, 2, 156, 1638] +[:mouse_move, 671, 125, 2, 157, 1639] +[:mouse_move, 659, 132, 2, 158, 1640] +[:mouse_move, 645, 142, 2, 159, 1641] +[:mouse_move, 632, 153, 2, 160, 1642] +[:mouse_move, 616, 164, 2, 161, 1643] +[:mouse_move, 583, 184, 2, 162, 1644] +[:mouse_move, 554, 198, 2, 163, 1645] +[:mouse_move, 519, 212, 2, 164, 1646] +[:mouse_move, 480, 224, 2, 165, 1647] +[:mouse_move, 445, 234, 2, 166, 1648] +[:mouse_move, 414, 246, 2, 167, 1649] +[:mouse_move, 393, 265, 2, 168, 1650] +[:mouse_move, 388, 276, 2, 169, 1651] +[:mouse_move, 386, 272, 2, 170, 1665] +[:mouse_move, 380, 272, 2, 171, 1666] +[:mouse_move, 366, 272, 2, 172, 1667] +[:mouse_move, 336, 266, 2, 173, 1668] +[:mouse_move, 313, 262, 2, 174, 1669] +[:mouse_move, 294, 258, 2, 175, 1670] +[:mouse_move, 278, 255, 2, 176, 1671] +[:mouse_move, 268, 254, 2, 177, 1672] +[:mouse_move, 263, 253, 2, 178, 1673] +[:mouse_move, 261, 252, 2, 179, 1674] +[:mouse_move, 260, 251, 2, 180, 1675] +[:mouse_move, 258, 250, 2, 181, 1676] +[:mouse_move, 256, 249, 2, 182, 1677] +[:mouse_move, 252, 249, 2, 183, 1678] +[:mouse_move, 251, 249, 2, 184, 1679] +[:mouse_move, 248, 249, 2, 185, 1680] +[:mouse_move, 246, 248, 2, 186, 1681] +[:mouse_move, 242, 247, 2, 187, 1682] +[:mouse_move, 234, 247, 2, 188, 1683] +[:mouse_move, 231, 247, 2, 189, 1684] +[:mouse_move, 230, 247, 2, 190, 1685] +[:mouse_move, 230, 246, 2, 191, 1688] +[:mouse_move, 229, 246, 2, 192, 1691] +[:mouse_move, 228, 246, 2, 193, 1692] +[:mouse_move, 227, 246, 2, 194, 1702] +[:mouse_move, 228, 246, 2, 195, 1834] +[:mouse_move, 229, 246, 2, 196, 1898] +[:mouse_move, 229, 245, 2, 197, 1968] +[:key_down_raw, 96, 0, 2, 198, 2024] +[:mouse_move, 230, 245, 2, 199, 2027] +[:key_up_raw, 96, 0, 2, 200, 2028] +[:key_down_raw, 13, 0, 2, 201, 2085] |
