diff --git a/res/barrier/fry.mp3 b/res/barrier/fry.mp3 index eb90e36..b6b08ec 100644 Binary files a/res/barrier/fry.mp3 and b/res/barrier/fry.mp3 differ diff --git a/res/blood0.png b/res/blood0.png new file mode 100644 index 0000000..1666167 Binary files /dev/null and b/res/blood0.png differ diff --git a/res/blood1.png b/res/blood1.png new file mode 100644 index 0000000..ba65f5e Binary files /dev/null and b/res/blood1.png differ diff --git a/res/blood2.png b/res/blood2.png new file mode 100644 index 0000000..1ceec88 Binary files /dev/null and b/res/blood2.png differ diff --git a/res/clip3/backdrop0.png b/res/clip3/backdrop0.png new file mode 100644 index 0000000..38cd951 Binary files /dev/null and b/res/clip3/backdrop0.png differ diff --git a/res/clip3/backdrop1.png b/res/clip3/backdrop1.png new file mode 100644 index 0000000..631b2ed Binary files /dev/null and b/res/clip3/backdrop1.png differ diff --git a/res/clip3/backdrop2.png b/res/clip3/backdrop2.png new file mode 100644 index 0000000..1b4744a Binary files /dev/null and b/res/clip3/backdrop2.png differ diff --git a/res/clip3/backdrop3.png b/res/clip3/backdrop3.png new file mode 100644 index 0000000..b920c24 Binary files /dev/null and b/res/clip3/backdrop3.png differ diff --git a/res/clip3/bigboi.png b/res/clip3/bigboi.png new file mode 100644 index 0000000..cc0906b Binary files /dev/null and b/res/clip3/bigboi.png differ diff --git a/res/clip3/sky0.png b/res/clip3/sky0.png new file mode 100644 index 0000000..ef2f32c Binary files /dev/null and b/res/clip3/sky0.png differ diff --git a/res/clip3/sky1.png b/res/clip3/sky1.png new file mode 100644 index 0000000..5c27a2e Binary files /dev/null and b/res/clip3/sky1.png differ diff --git a/res/clip3/sky2.png b/res/clip3/sky2.png new file mode 100644 index 0000000..8ac6ba2 Binary files /dev/null and b/res/clip3/sky2.png differ diff --git a/res/clip3/smallboi.png b/res/clip3/smallboi.png new file mode 100644 index 0000000..ead2f8e Binary files /dev/null and b/res/clip3/smallboi.png differ diff --git a/res/clip3/sun.png b/res/clip3/sun.png new file mode 100644 index 0000000..a26b8de Binary files /dev/null and b/res/clip3/sun.png differ diff --git a/res/enemies/metalhurt.mp3 b/res/enemies/metalhurt.mp3 new file mode 100644 index 0000000..358c091 Binary files /dev/null and b/res/enemies/metalhurt.mp3 differ diff --git a/res/final/finalboss.mp3 b/res/final/finalboss.mp3 new file mode 100644 index 0000000..c06efe5 Binary files /dev/null and b/res/final/finalboss.mp3 differ diff --git a/res/final/roar1.mp3 b/res/final/roar1.mp3 new file mode 100644 index 0000000..b6a9184 Binary files /dev/null and b/res/final/roar1.mp3 differ diff --git a/res/final/roar2.mp3 b/res/final/roar2.mp3 new file mode 100644 index 0000000..7101372 Binary files /dev/null and b/res/final/roar2.mp3 differ diff --git a/res/level4/backdrop.png b/res/level4/backdrop.png new file mode 100644 index 0000000..74d91e9 Binary files /dev/null and b/res/level4/backdrop.png differ diff --git a/res/level4/map.png b/res/level4/map.png new file mode 100644 index 0000000..7d489ee Binary files /dev/null and b/res/level4/map.png differ diff --git a/res/level4/map.yaml b/res/level4/map.yaml new file mode 100644 index 0000000..6e6f4cb --- /dev/null +++ b/res/level4/map.yaml @@ -0,0 +1,103 @@ +seed: 1234 + +images: +- res/level4/map.png +- res/level4/map_ent.png + +tiles: +- class: ground + texture: res/level1/ground.png + noise: 1.0 + color: [0, 0, 0] + +- class: ground + texture: res/level1/wood.png + noise: 0.0 + color: [101, 101, 101] + +- class: ground + texture: res/level1/sand.png + noise: 3.0 + color: [200, 200, 200] + +- class: ground + texture: res/level3/rock.png + noise: 0.7 + color: [75, 50, 50] + +- class: B@back + texture: res/level1/back.png + noise: 1.0 + color: [240, 240, 240] + +- class: B@backwood + texture: res/level1/wood_back.png + noise: 0.0 + color: [160, 160, 160] + +- class: B@back + texture: res/level3/back_metal.png + noise: 0.0 + color: [210, 140, 140] + +- class: B@back + texture: res/level3/back_metal1.png + noise: 0.0 + color: [210, 145, 145] + +- class: B@back + texture: res/level3/back_rock.png + noise: 1.5 + color: [220, 220, 220] + +areas: +- name: water + color: [0, 0, 255] +- name: break_wood + color: [0, 255, 150] +- name: gate + color: [100, 255, 150] +- name: enemy_killer + color: [255, 240, 0] +- name: kill + color: [255, 0, 0] + +points: +- name: rock + color: [140, 140, 200] + +- name: magmarock + color: [140, 175, 200] + +- name: box + color: [255, 140, 200] + +- name: player + color: [100, 255, 50] + +- name: rockman + color: [255, 100, 50] + +- name: bird + color: [60, 160, 60] + +- name: door + color: [0, 51, 255] + +- name: button0 + color: [255, 0, 255] + +- name: button1 + color: [255, 10, 255] + +- name: button2 + color: [255, 20, 255] + +- name: light1l + color: [255, 190, 0] + +- name: light + color: [100, 0, 0] + +- name: rockman_spawner + color: [255, 0, 110] diff --git a/res/level4/map_ent.png b/res/level4/map_ent.png new file mode 100644 index 0000000..9d0b186 Binary files /dev/null and b/res/level4/map_ent.png differ diff --git a/res/level4/music.mp3 b/res/level4/music.mp3 new file mode 100644 index 0000000..1bd2450 Binary files /dev/null and b/res/level4/music.mp3 differ diff --git a/src/game/entities/barrier.nim b/src/game/entities/barrier.nim index 15bcfe2..1351d86 100644 --- a/src/game/entities/barrier.nim +++ b/src/game/entities/barrier.nim @@ -90,6 +90,8 @@ proc create_barrier_segment(this: Barrier, sprite: string, pos: Vec2f, size: int # Center barriers sprite.position = pos + vec2f(size.toFloat * 0.5, size.toFloat * 0.5) + if hor: + sprite.position = vec2f(sprite.position.x + size.toFloat, sprite.position.y) this.sprites.add(sprite) diff --git a/src/game/entities/enemy.nim b/src/game/entities/enemy.nim index 24f944d..1e6d339 100644 --- a/src/game/entities/enemy.nim +++ b/src/game/entities/enemy.nim @@ -9,13 +9,13 @@ import sequtils import ../userdata type - EnemyKind = enum + EnemyKind* = enum ekRockman, ekRockmanSpawner, ekBird Enemy* = ref object - case kind: EnemyKind + case kind*: EnemyKind of ekRockman: retreat_timer: float retreat_goal: float @@ -24,6 +24,7 @@ type dumb: int of ekRockmanSpawner: spawn_timer: float + spawn_timer_def*: float children: seq[Enemy] max_children: int of ekBird: @@ -71,13 +72,14 @@ proc create_rockman_spawner*(pos: Vec2f, space: Space, id: int): Enemy = result.phys_shape.friction = 1.0 result.phys_body.position = v(pos.x, pos.y - 40.0) - result.hurt_wav = load_sound("res/enemies/rockman_hurt.mp3") + result.hurt_wav = load_sound("res/enemies/metalhurt.mp3") result.user_data = make_enemy_userdata(id) result.phys_shape.userData = addr result.user_data result.health = 6.0 result.spawn_timer = 0.0 result.max_children = 5 + result.spawn_timer_def = 15.0 proc create_bird*(pos: Vec2f, space: Space, id: int): Enemy = result = base_create(ekBird) @@ -90,7 +92,7 @@ proc create_bird*(pos: Vec2f, space: Space, id: int): Enemy = result.phys_shape.friction = 0.3 result.phys_body.position = v(pos.x, pos.y - 10.0) - result.hurt_wav = load_sound("res/enemies/rockman_hurt.mp3") + result.hurt_wav = load_sound("res/enemies/metalhurt.mp3") result.user_data = make_enemy_userdata(id) result.phys_shape.userData = addr result.user_data @@ -156,7 +158,7 @@ proc update*(this: var Enemy, player: Player, objects: var seq[PhysicalObject], elif this.spawn_timer < 5.0: this.sprite.start_anim("idle") if this.spawn_timer < 0.0 and this.children.len < this.max_children: - this.spawn_timer = 15.0 + this.spawn_timer = this.spawn_timer_def var pos = vec2f(this.sprite.center_position.x - 40.0, this.sprite.center_position.y) var dumb = -1 if this.sprite.scale.x < 0.0: @@ -180,7 +182,7 @@ proc update*(this: var Enemy, player: Player, objects: var seq[PhysicalObject], (scale.x > 0.0 and player_dir.x > 0.0): # Player walked into our attack! this.turn_timer = 0.0 - elif player_dist < 150.0: + elif player_dist < 190.0: # Move quickly towards the player, but with turn-around inertia if (scale.x < 0.0 and player_dir.x > 0.0) or (scale.x > 0.0 and player_dir.x < 0.0): @@ -188,6 +190,9 @@ proc update*(this: var Enemy, player: Player, objects: var seq[PhysicalObject], this.turn_timer = 3.0 else: this.phys_body.velocity = v(player_dir.x * 120.0, this.phys_body.velocity.y) + if player_dist < 75.0 and player_dir.y < -0.5: + if player.try_hurt(): + this.sprite.start_anim("bloody") else: this.toss_timer -= dt diff --git a/src/game/entities/platform.nim b/src/game/entities/platform.nim index 4a1be4e..e302a86 100644 --- a/src/game/entities/platform.nim +++ b/src/game/entities/platform.nim @@ -16,7 +16,8 @@ type Platform* = ref object track_body*: Body track_shape*: Shape spring*: Constraint - speed: float + speed*: float + distt: float progress: float p0: Vect @@ -63,7 +64,8 @@ proc create_platform*(p0: Vect, p1: Vect, lanchor0: Vec2f, lanchor1: Vec2f, spac result.p0 = p0 result.p1 = p1 - result.speed = 50.0 / vdist(result.p0, result.p1) + result.distt = vdist(result.p0, result.p1) + result.speed = 50.0 var points: seq[Vec2f] points.add(lanchor0) @@ -107,10 +109,11 @@ proc update*(this: var Platform, player: Player, control_platform: Option[Platfo player.phys_body.position = v(-100.0, -100.0) player.fall_sound.pause() player.step_sound.pause() + let mspeed = this.speed / this.distt if glfw_window.getKey(GLFWKey.A) == GLFW_PRESS: - this.progress -= dt * this.speed + this.progress -= dt * mspeed elif glfw_window.getKey(GLFWKey.D) == GLFW_PRESS: - this.progress += dt * this.speed + this.progress += dt * mspeed # Stop controlling if glfw_window.getKey(GLFWKey.E) == GLFW_PRESS and not this.just_hopped: diff --git a/src/game/entities/player.nim b/src/game/entities/player.nim index 413c4b2..89bf194 100644 --- a/src/game/entities/player.nim +++ b/src/game/entities/player.nim @@ -38,6 +38,20 @@ type Player* = ref object step_sound*: AudioHandle fall_sound*: AudioHandle + blood0: Sprite + blood1: Sprite + blood2: Sprite + + health*: float + hurt_timer: float + + +proc try_hurt*(this: Player): bool = + if this.hurt_timer < 0.0: + this.health -= 1.0 + this.hurt_timer = 2.0 + this.phys_body.applyImpulseAtWorldPoint(v(0.0, -8000.0), this.phys_body.position) + return true # This must be here to avoid circular dependency hell import enemy @@ -70,10 +84,17 @@ proc create_player*(pos: Vec2f, space: Space): Player = result.step_sound = create_sound(result.step_wav, true) result.fall_sound = create_sound(result.fall_wav, true) - let points = @[vec2f(0.0, 0.0), vec2f(20.0, 0.0), vec2f(15.0, 5.0), vec2f(15.0, -5.0)] - result.ind_line = create_line(points, 4.0) + result.blood0 = create_sprite("res/blood0.png") + result.blood0.clear_fx = false + result.blood1 = create_sprite("res/blood1.png") + result.blood1.clear_fx = false + result.blood2 = create_sprite("res/blood2.png") + result.blood2.clear_fx = false + result.health = 5.0 + let points = @[vec2f(0.0, 0.0), vec2f(20.0, 0.0), vec2f(15.0, 5.0), vec2f(20.0, 0.0), vec2f(15.0, -5.0)] + result.ind_line = create_line(points, 4.0) proc ground_query_foot(sh: Shape, p: Vect, n: Vect, a: Float, data: pointer) {.cdecl.} = if sh.userData == nil: @@ -103,6 +124,10 @@ proc query_hit(sh: Shape, p: Vect, n: Vect, a: Float, data: pointer) {.cdecl.} = hurt(datac[].enemies[enemy_idx], p) +proc deinit*(this: Player) = + this.step_sound.pause() + this.fall_sound.pause() + proc hit(this: Player, enemies: seq[Enemy]): bool = let rays = this.phys_body.position + v(0.0, 0.0) var raye = this.phys_body.position + v(34.0, 23.0) @@ -212,6 +237,7 @@ proc toss(this: Player, enemies: seq[Enemy], objects: seq[PhysicalObject]) = segmentQuery(this.phys_space, rays, raye2, Float(14.0), filter, query_toss, addr query_data) proc update*(this: var Player, enemies: seq[Enemy], objects: seq[PhysicalObject]) = + this.hurt_timer -= dt # Ground check let rfootp = this.phys_body.position + v(34.0, 25.0) let lfootp = this.phys_body.position + v(-34.0, 25.0) @@ -361,3 +387,13 @@ proc draw_fx*(this: var Player) = renderer.draw(this.lantern) if this.in_toss: renderer.draw(this.ind_line) + + this.blood0.center_position = renderer.camera.center + this.blood1.center_position = renderer.camera.center + this.blood2.center_position = renderer.camera.center + if this.health < 2.0: + renderer.draw(this.blood2) + elif this.health < 3.0: + renderer.draw(this.blood1) + elif this.health < 4.0: + renderer.draw(this.blood0) diff --git a/src/game/scenes/level.nim b/src/game/scenes/level.nim index 9e325d1..d17aa73 100644 --- a/src/game/scenes/level.nim +++ b/src/game/scenes/level.nim @@ -29,7 +29,7 @@ type Level* = ref object physics_space*: Space physical_objects*: seq[PhysicalObject] barriers*: seq[Barrier] - enemies: seq[Enemy] + enemies*: seq[Enemy] # Must be manually created platforms*: seq[Platform] doors: seq[Door] @@ -84,7 +84,7 @@ proc init_no_map(this: var Level, scale: int) = let point = this.map.points[str][0] this.physical_objects.add(create_button(point, this.physics_space, this.physical_objects.len, addr this.physical_objects)) - this.buttons_idx[0] = this.physical_objects.len - 1 + this.buttons_idx[i] = this.physical_objects.len - 1 # Load barriers @@ -128,8 +128,9 @@ proc init_no_map(this: var Level, scale: int) = # Removes all physical objects EXCEPT the world, and reinits proc restart(this: var Level) = for obj in this.physical_objects: - this.physics_space.removeBody(obj.phys_body) - this.physics_space.removeShape(obj.phys_shape) + if not obj.dead: + this.physics_space.removeBody(obj.phys_body) + this.physics_space.removeShape(obj.phys_shape) for barrier in this.barriers: if not barrier.broken: this.physics_space.removeShape(barrier.phys_shape) @@ -138,6 +139,8 @@ proc restart(this: var Level) = this.physics_space.removeBody(enemy.phys_body) this.physics_space.removeShape(enemy.phys_shape) + + this.player.deinit() this.physics_space.removeBody(this.player.phys_body) this.physics_space.removeShape(this.player.phys_shape) @@ -225,6 +228,7 @@ proc update*(this: var Level): bool = exit = exit or door.update(this.player) if exit: + this.player.deinit() return true @@ -252,8 +256,11 @@ proc update*(this: var Level): bool = # Check die areas for area in this.kill: let pos = this.player.sprite.position - if pos.x > area.x and pos.y > area.y and pos.x < area.x + area.z and pos.y < area.y + area.w: + if pos.x > area.x and pos.y > area.y and pos.x < area.z and pos.y < area.w: this.die() + + if this.player.health < 0.0: + this.die() if this.die_timer > 0.0: this.die_timer -= dt diff --git a/src/game/scenes/level1.nim b/src/game/scenes/level1.nim index 86cf8b4..68db2b1 100644 --- a/src/game/scenes/level1.nim +++ b/src/game/scenes/level1.nim @@ -7,13 +7,14 @@ import cutsc1 type Level1Scene* = ref object of Scene music: WavHandle + musich: AudioHandle level: Level tut: seq[Sprite] method init(this: Level1Scene) = echo "Init!" this.music = load_sound("res/level1/music.mp3") - discard play_sound(this.music, true) + this.musich = play_sound(this.music, true) this.level.init("res/level1/map.yaml", "res/level1/backdrop.png", "none", 20) this.tut.add(create_sprite("res/tutorial/tut000.png")) @@ -36,7 +37,8 @@ method init(this: Level1Scene) = method update(this: Level1Scene) = if this.level.update(): - goto_scene(CutScene1) + this.musich.pause() + goto_scene(CutScene1()) method render(this: Level1Scene) = this.level.draw() for tut in this.tut: diff --git a/src/game/scenes/level2.nim b/src/game/scenes/level2.nim index c4089ae..dd7362d 100644 --- a/src/game/scenes/level2.nim +++ b/src/game/scenes/level2.nim @@ -10,6 +10,7 @@ import level3 type Level2Scene* = ref object of Scene music: WavHandle + musich: AudioHandle level: Level tut: seq[Sprite] open: bool @@ -17,7 +18,7 @@ type Level2Scene* = ref object of Scene method init(this: Level2Scene) = this.music = load_sound("res/level1/music.mp3") - discard play_sound(this.music, true) + this.musich = play_sound(this.music, true) this.level.init("res/level2/map.yaml", "res/level2/backdrop.png", "res/level2/backdrop_fx.png", 20) let points = @[vec2f(92.0 * 20.0 + 5.0, 75.0 * 20.0 + 15.0), vec2f(98.0 * 20.0, 75.0 * 20.0 + 15.0), vec2f(98.0 * 20.0, 59.0 * 20.0)] @@ -43,7 +44,7 @@ method init(this: Level2Scene) = method update(this: Level2Scene) = if this.level.update(): - echo "Scene change" + this.musich.pause() goto_scene(Level3Scene()) let button_obj = this.level.physical_objects[this.level.buttons_idx[0]] if button_obj.active: diff --git a/src/game/scenes/level3.nim b/src/game/scenes/level3.nim index 452c795..f01c120 100644 --- a/src/game/scenes/level3.nim +++ b/src/game/scenes/level3.nim @@ -10,31 +10,32 @@ import cutsc2 type Level3Scene* = ref object of Scene music: WavHandle + musich: AudioHandle level: Level open: bool event_played: bool cable: Line run_sound: WavHandle + first_frame: bool method init(this: Level3Scene) = this.music = load_sound("res/level3/music.mp3") - discard play_sound(this.music, true) + this.musich = play_sound(this.music, true) this.level.init("res/level3/map.yaml", "res/level1/backdrop.png", "none", 20) let points = @[vec2f(71.0 * 20.0 + 5.0, 87.0 * 20.0 + 15.0), vec2f(75.0 * 20.0, 87.0 * 20.0 + 15.0), vec2f(75.0 * 20.0, 83.0 * 20.0)] this.cable = create_line(points, 8.0) this.cable.color = vec4f(0.1, 0.1, 0.1, 0.7) this.run_sound = load_sound("res/level3/run.mp3") + this.first_frame = true method update(this: Level3Scene) = if this.level.reinit: this.event_played = false + this.first_frame = true - if this.level.update(): - goto_scene(CutScene2()) - let button_obj = this.level.physical_objects[this.level.buttons_idx[0]] if button_obj.active: this.cable.fx_color = vec4f(1.0, 0.4, 0.4, 1.0) @@ -44,13 +45,21 @@ method update(this: Level3Scene) = this.cable.fx_color = vec4f(0, 0, 0, 0) if not this.event_played: - if this.level.player.sprite.center_position.y < 40.0 * 20.0: + if this.level.player.sprite.center_position.y < 40.0 * 20.0 and not this.first_frame: + echo this.level.player.sprite.center_position.y + echo this.first_frame discard this.run_sound.play_sound() for obj in this.level.physical_objects: if obj.kind == okMagmaRock: let p = obj.phys_body.position obj.phys_body.applyImpulseAtWorldPoint(v(10000.0, 0.0), p) this.event_played = true + + if this.level.update(): + this.musich.pause() + goto_scene(CutScene2()) + + this.first_frame = false method render(this: Level3Scene) = this.level.draw() diff --git a/src/game/scenes/level4.nim b/src/game/scenes/level4.nim index 452c795..a1cb994 100644 --- a/src/game/scenes/level4.nim +++ b/src/game/scenes/level4.nim @@ -2,56 +2,92 @@ include ../../engine/base import ../../engine/map/map_loader import ../../engine/graphics/sprite import ../entities/player +import ../entities/enemy import ../entities/platform import ../entities/physical_object import ../../engine/base/renderer as rnd import level -import cutsc2 -type Level3Scene* = ref object of Scene +type Level4Scene* = ref object of Scene music: WavHandle + musich: AudioHandle + final: WavHandle + finalh: AudioHandle + roar1: WavHandle + roar2: WavHandle level: Level open: bool - event_played: bool - cable: Line - run_sound: WavHandle - -method init(this: Level3Scene) = - this.music = load_sound("res/level3/music.mp3") - discard play_sound(this.music, true) - this.level.init("res/level3/map.yaml", "res/level1/backdrop.png", "none", 20) - let points = @[vec2f(71.0 * 20.0 + 5.0, 87.0 * 20.0 + 15.0), vec2f(75.0 * 20.0, 87.0 * 20.0 + 15.0), - vec2f(75.0 * 20.0, 83.0 * 20.0)] - this.cable = create_line(points, 8.0) - this.cable.color = vec4f(0.1, 0.1, 0.1, 0.7) - this.run_sound = load_sound("res/level3/run.mp3") + event_timer: float + roared: bool + roared2: bool + roared3: bool +method init(this: Level4Scene) = + this.music = load_sound("res/level4/music.mp3") + this.final = load_sound("res/final/finalboss.mp3") + this.roar1 = load_sound("res/final/roar1.mp3") + this.roar2 = load_sound("res/final/roar2.mp3") + this.finalh = this.final.create_sound(true) + this.musich = play_sound(this.music, true) + this.level.init("res/level4/map.yaml", "res/level4/backdrop.png", "none", 20) + + this.level.platforms.add(create_platform( + v(60.0 * 20.0 + 30.0, 86.0 * 20.0), + v(173 * 20.0, 31.0 * 20.0), + vec2f(55.0 * 20.0, 86.0 * 20.0), + vec2f(176 * 20.0, 31.0 * 20.0), + this.level.physics_space + )) + this.level.platforms[0].speed = 60.0 + this.event_timer = -1.0 -method update(this: Level3Scene) = +method update(this: Level4Scene) = if this.level.reinit: - this.event_played = false + for enemy in this.level.enemies: + if enemy.kind == ekRockmanSpawner: + enemy.sprite.scale = vec2f(-1.0, 1.0) + enemy.spawn_timer_def = 7.0 + this.event_timer = -1.0 + this.musich.set_volume(0.8) + this.finalh.pause() + this.roared = false + this.roared2 = false + this.roared3 = false if this.level.update(): - goto_scene(CutScene2()) + this.musich.pause() + goto_scene(Level4Scene()) + + var op = true + for button in this.level.buttons_idx: + if button > 0: + op = op and this.level.physical_objects[button].active - let button_obj = this.level.physical_objects[this.level.buttons_idx[0]] - if button_obj.active: - this.cable.fx_color = vec4f(1.0, 0.4, 0.4, 1.0) - this.open = true - this.level.barriers[1].health = 0.0 + if op: + this.level.barriers[0].health = 0.0 + + if this.event_timer >= 0.0: + this.event_timer += dt + this.musich.set_volume(max(1.0 - this.event_timer, 0.0)) + this.finalh.set_volume(min(this.event_timer, 1.0)) + this.finalh.resume() + + if this.event_timer >= 4.0 and not this.roared: + discard this.roar1.play_sound(false) + this.roared = true + + if this.event_timer >= 12.0 and not this.roared2: + discard this.roar1.play_sound(false) + this.roared2 = true + + if this.event_timer >= 16.0 and not this.roared3: + discard this.roar2.play_sound(false) + this.roared3 = true else: - this.cable.fx_color = vec4f(0, 0, 0, 0) - - if not this.event_played: - if this.level.player.sprite.center_position.y < 40.0 * 20.0: - discard this.run_sound.play_sound() - for obj in this.level.physical_objects: - if obj.kind == okMagmaRock: - let p = obj.phys_body.position - obj.phys_body.applyImpulseAtWorldPoint(v(10000.0, 0.0), p) - this.event_played = true - -method render(this: Level3Scene) = - this.level.draw() - renderer.draw(this.cable) \ No newline at end of file + if this.level.player.sprite.position.x > 90.0 * 20.0: + this.event_timer = 0.0 + + +method render(this: Level4Scene) = + this.level.draw() \ No newline at end of file diff --git a/src/main.nim b/src/main.nim index 5780685..47ddaeb 100644 --- a/src/main.nim +++ b/src/main.nim @@ -3,12 +3,13 @@ import nimgl/[glfw] #import game/scenes/level1 #import game/scenes/cutsc1 #import game/scenes/level2 -#import game/scenes/level3 -import game/scenes/cutsc2 +import game/scenes/level3 +#import game/scenes/cutsc2 +#import game/scenes/level4 include engine/base -goto_scene(CutScene2()) +goto_scene(Level3Scene()) proc update() =