diff options
| author | realtradam <[email protected]> | 2022-01-26 03:36:56 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-01-26 03:36:56 -0500 |
| commit | b8d8f3b80643fcaa324dbb7c83e36781868687a9 (patch) | |
| tree | 3441fb892010854d523f8f0a968f07490cd39e8f /src | |
| parent | 5601426017b6a2fc81a56f7c83eb1ee837f2b9c1 (diff) | |
| download | orc-arena-of-time-b8d8f3b80643fcaa324dbb7c83e36781868687a9.tar.gz orc-arena-of-time-b8d8f3b80643fcaa324dbb7c83e36781868687a9.zip | |
working first level
Diffstat (limited to 'src')
| -rw-r--r-- | src/levels.rb | 67 | ||||
| -rw-r--r-- | src/logic.rb | 59 |
2 files changed, 91 insertions, 35 deletions
diff --git a/src/levels.rb b/src/levels.rb index 2f7bf2a..fbdd1b6 100644 --- a/src/levels.rb +++ b/src/levels.rb @@ -6,31 +6,78 @@ Levels = [] # First level level0 = { - player_spawn: Rl::Vector2.new(120,300), + player_spawn: Rl::Vector2.new(425,325), scissor_size: Path.new( lambda do |time| [250, 250] + end, + lambda do |time| + [250, + 250] end ), scissor_path: Path.new( lambda do |time| - [Math.bezier([200, 200, 1183, 200],time)-150, - Math.bezier([200, 1183, 200, 200],time)-150] + xstart = 492 + ystart = 353 + xstartnode = 786 + ystartnode = 374 + xendnode = 763 + yendnode = 373 + xend = 787 + yend = 142 + [Math.bezier([xstart, xstartnode, xendnode, xend],time)-(250/2), + Math.bezier([ystart, ystartnode, yendnode, yend],time)-(250/2)] + end, + lambda do |time| + xstart = 787 + ystart = 142 + xstartnode = -39 + ystartnode = 1 + xendnode = 174 + yendnode = 465 + xend = 276 + yend = 569 + [Math.bezier([xstart, xstartnode, xendnode, xend],time)-(250/2), + Math.bezier([ystart, ystartnode, yendnode, yend],time)-(250/2)] end ), + scissor_speed: [1.0/6.0, 1.0/10.0], end_goal: [40,40,10,10], walls: [ - [250,250, 250,150], - [350,200, 050,350], - [070,470, 200,200], - [470,470, 200,020], + [308,182,290,86], + [598,182,118,124], + [596,372,118,90], + [714,372,12,90], + [726,404,116,34], + [842,84,12,354], + [810,84,32,34], + [214,84,596,24], + [86,84,128,34], + [518,128,20,26], + [234,182,42,36], + [74,84,12,130], + [166,244,142,34], + [74,244,48,34], + [310,268,84,224], + [310,492,52,38], + [74,340,144,34], + [262,340,48,34], + [74,436,80,34], + [198,436,112,34], + [74,532,12,122], + [86,596,64,34], + [31,84,43,570], + [86,629,320,25], + [406,492,54,162], + [394,438,202,54], ], damage_areas: [ - [10, 0,0, 100,100], + #[10, 0,0, 100,100], ], damage_walls: [ - [10, 350,200, 050,350], + #[10, 350,200, 050,350], ] } @@ -90,7 +137,7 @@ FECS::Sys.new('DestroyLevel') do end hitbox_cmp.delete end - + FECS::Cmp::DamageHitbox.reverse_each do |hitbox_cmp| hitbox_cmp.delete end diff --git a/src/logic.rb b/src/logic.rb index 6fb5baf..f5b1c13 100644 --- a/src/logic.rb +++ b/src/logic.rb @@ -42,10 +42,10 @@ FECS::Cmp.new('ScissorBox', FECS::Cmp.new('ScissorTime', :time) FECS::Cmp.new('DamageHitbox', - :rec, - damage: 1, - offset_x: 0, - offset_y: 0) + :rec, + damage: 1, + offset_x: 0, + offset_y: 0) FECS::Cmp.new('EndGoal', :rec) #ScissorPath = Path.new( @@ -63,7 +63,7 @@ Input = FECS::Cmp::Input.new lancelot = Tileset.new(texture: Rl::Texture.new('./assets/lancelot_.png')) FECS::Cmp::Sprite.new( - texture: Rl::Texture.new('./assets/map1.png'), + texture: Rl::Texture.new('./assets/mapinit.png'), source_rec: Rl::Rectangle.new(0,0,448,336), dest_rec: Rl::Rectangle.new(0,0,448*2,336*2) ) @@ -123,9 +123,10 @@ Player = FECS::Ent.new( max_speed: 400, ), FECS::Cmp::Hitbox.new( - rec: Rl::Rectangle.new(0,0,16*2,20*2), + #rec: Rl::Rectangle.new(0,0,16*2,20*2), + rec: Rl::Rectangle.new(0,0,16*2,10*2), offset_x: 4*2, - offset_y: 4*2 + offset_y: 14*2 ), ) @@ -367,8 +368,14 @@ FECS::Scn::Play.add( FECS::Sys.new('Scissor') do player_ent = FECS::Cmp::Player.first.entity if player_ent.component[FECS::Cmp::Player].moved - FECS::Cmp::ScissorTime.first.time += Rl.frame_time * 1/8 - FECS::Cmp::ScissorTime.first.time %= 1 + if FECS::Cmp::ScissorTime.first.time < Levels[CurrentLevel.level][:scissor_path].paths.length - 0.00001 + FECS::Cmp::ScissorTime.first.time += Rl.frame_time * Levels[CurrentLevel.level][:scissor_speed][FECS::Cmp::ScissorTime.first.time.to_i] + if FECS::Cmp::ScissorTime.first.time >= Levels[CurrentLevel.level][:scissor_path].paths.length - 0.00001 + FECS::Cmp::ScissorTime.first.time = Levels[CurrentLevel.level][:scissor_path].paths.length - 0.00001 + end + else + FECS::Cmp::ScissorTime.first.time = Levels[CurrentLevel.level][:scissor_path].paths.length - 0.00001 + end end end, FECS::Sys.new('Render') do @@ -421,24 +428,26 @@ FECS::Scn::Play.add( FelECS::Sys.new('DebugRenderHitbox') do scissor_path = Levels[CurrentLevel.level][:scissor_path].call(FECS::Cmp::ScissorTime.first.time) scissor_size = Levels[CurrentLevel.level][:scissor_size].call(FECS::Cmp::ScissorTime.first.time) - Rl.scissor_mode( - x: scissor_path[0], - y: scissor_path[1], - width: scissor_size[0], - height: scissor_size[1]) do - FECS::Cmp::Hitbox.each do |hitbox| - #hitbox.rec.draw(color: BLACK) - hitbox.rec.draw_lines(line_thick: 2, color: BLUE) - end - end - if Input.show_debug - faded_blue = Rl::Color.new(0,121,241,30) - FECS::Cmp::Hitbox.each do |hitbox| - #hitbox.rec.draw(color: BLACK) - hitbox.rec.draw_lines(line_thick: 2, color: faded_blue) + if Input.show_debug + Rl.scissor_mode( + x: scissor_path[0], + y: scissor_path[1], + width: scissor_size[0], + height: scissor_size[1]) do + FECS::Cmp::Hitbox.each do |hitbox| + #hitbox.rec.draw(color: BLACK) + hitbox.rec.draw_lines(line_thick: 2, color: BLUE) + end end + end + if Input.show_debug + faded_blue = Rl::Color.new(0,121,241,30) + FECS::Cmp::Hitbox.each do |hitbox| + #hitbox.rec.draw(color: BLACK) + hitbox.rec.draw_lines(line_thick: 2, color: faded_blue) end - Rl::Rectangle.new(scissor_path[0], scissor_path[1], scissor_size[0], scissor_size[1]).draw_lines(line_thick: 3, color: RED) + end + Rl::Rectangle.new(scissor_path[0]-1, scissor_path[1]-1, scissor_size[0]+1, scissor_size[1]+1).draw_lines(line_thick: 3, color: RED) end ) |
