crane_construction 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/CHANGELOG.md +51 -0
- data/lib/README.md +25 -0
- data/lib/crane_construction.gemspec +33 -0
- data/lib/crane_construction.rb +10 -0
- data/lib/lib/items/brick.rb +101 -0
- data/lib/lib/items/brickyard.rb +55 -0
- data/lib/lib/items/crane.rb +23 -0
- data/lib/lib/items/hook.rb +118 -0
- data/lib/lib/user_interface/background.rb +17 -0
- data/lib/lib/user_interface/game_window.rb +107 -0
- data/lib/lib/user_interface/infopane.rb +34 -0
- data/lib/media/circle.png +0 -0
- data/lib/media/square.png +0 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f214fa9d4c62b31a5b38c67dd8f96a21f910a5e154d6ddd50d78665375f88805
|
4
|
+
data.tar.gz: 0a1fc0bcf8412363e26c19c5ac0afd1fafe69f91dfe2d0b4fd2cb20a45f28499
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f169d3b4da6116f9175e77a74cf1ab5299bdfce2dbc830e9974d22a7a528e7ece82be801a9f6666fe1262f7b0d5e25f9b24ae80648a6ddda5475577d4b95cb7
|
7
|
+
data.tar.gz: 6dc95e08e90ff2cc9692490f09073753335c859eba267873ea5e313e58fa9d1c37a2458e047e8806f38e01ed9b7ee215ae7a91a7a102bb4f9c729ad30b9fadf5
|
data/lib/CHANGELOG.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
4
|
+
|
5
|
+
## Not released yet
|
6
|
+
### Added
|
7
|
+
### Changed
|
8
|
+
### Fixed
|
9
|
+
### Removed
|
10
|
+
|
11
|
+
|
12
|
+
## [v3.1](../../tags/v3.1) – 2022-08-29
|
13
|
+
- marketing media
|
14
|
+
- timer
|
15
|
+
- Rubygems gem and Itch.io project
|
16
|
+
|
17
|
+
|
18
|
+
## [v3](../../tags/v3) – 2022-08-29
|
19
|
+
### Added
|
20
|
+
- controls and summary in README
|
21
|
+
- bricks falling down when dropped in air
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
- bricks rotate so that their top stays at the same height
|
25
|
+
- distinct key presses instead of continuous holding
|
26
|
+
- hook can hold also other bricks than the first one
|
27
|
+
- range of hook-attractedness limited
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
- held bricks can again be rotated
|
31
|
+
|
32
|
+
|
33
|
+
## [v2](../../tags/v2) – 2022-08-27
|
34
|
+
### Added
|
35
|
+
- one brick for a start
|
36
|
+
- brickyard can produce more bricks
|
37
|
+
- hook can hold and drop the first brick
|
38
|
+
|
39
|
+
### Changed
|
40
|
+
- movement curtailed to working area
|
41
|
+
|
42
|
+
### Fixed
|
43
|
+
- brickyard is drawing also itself
|
44
|
+
|
45
|
+
|
46
|
+
## [v1](../../tags/v1) – 2022-08-24
|
47
|
+
### Added
|
48
|
+
- close, reset and debug hotkeys
|
49
|
+
- basic scene
|
50
|
+
- hook follows mouse
|
51
|
+
|
data/lib/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Crane Construciton
|
2
|
+
- game jam: https://itch.io/jam/gosu-game-jam-3
|
3
|
+
- gem: (TODO link to RubyGems)
|
4
|
+
- repository: https://gitlab.com/rasunadon/crane-construction
|
5
|
+
- bug tracker: https://gitlab.com/rasunadon/crane-construction/issues
|
6
|
+
- licence: CC-BY-SA 3.0, Detros
|
7
|
+
- email: rasunadon@seznam.cz
|
8
|
+
|
9
|
+
_Crane Construction_ was created during the third Gosu Game Jam which run for
|
10
|
+
two weeks between 2022-08-14 and 2022-08-29. Your goal is to pile bricks as
|
11
|
+
you like as blueprints have not been finished yet. Game thus doesn't end.
|
12
|
+
|
13
|
+
|
14
|
+
# Controls
|
15
|
+
- hook movement: mouse
|
16
|
+
- start holding / drop: left mouse button
|
17
|
+
- rotate held brick: R
|
18
|
+
- new brick: N
|
19
|
+
- show debug info: Tab
|
20
|
+
- reset: Backspace
|
21
|
+
- quit: Esc
|
22
|
+
|
23
|
+
|
24
|
+
# Other documentation
|
25
|
+
- CHANGELOG: list of what has been added/changed/fixed/removed in given version
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'crane_construction'
|
5
|
+
spec.version = '0.3.1'
|
6
|
+
spec.date = '2022-08-29'
|
7
|
+
spec.license = 'CC-BY-SA-3.0'
|
8
|
+
|
9
|
+
spec.summary = "A simulation construction game"
|
10
|
+
spec.description = "Crane Construction is a simulation construction game. It
|
11
|
+
was created during the third Gosu Game Jam."
|
12
|
+
spec.files = Rake::FileList["lib/lib/**/*",
|
13
|
+
"lib/media/*.png",
|
14
|
+
"lib/CHANGELOG.md",
|
15
|
+
"lib/crane_construction.gemspec",
|
16
|
+
"lib/crane_construction.rb",
|
17
|
+
"lib/README.md"]
|
18
|
+
|
19
|
+
spec.author = 'Detros'
|
20
|
+
spec.homepage = 'https://rasunadon.itch.io/crane-construction'
|
21
|
+
spec.email = 'rasunadon@seznam.cz'
|
22
|
+
spec.metadata = {
|
23
|
+
"source_code_uri" => "https://gitlab.com/rasunadon/crane_construction",
|
24
|
+
"bug_tracker_uri" => "https://gitlab.com/rasunadon/crane-construction/issues",
|
25
|
+
"documentation_uri" => "https://gitlab.com/rasunadon/crane-construction/blob/master/README.md",
|
26
|
+
"changelog_uri" => "https://gitlab.com/rasunadon/crane-construction/blob/master/CHANGELOG.md",
|
27
|
+
"homepage_uri" => "https://rasunadon.itch.io/crane-construction",
|
28
|
+
}
|
29
|
+
|
30
|
+
spec.platform = Gem::Platform::RUBY
|
31
|
+
spec.add_runtime_dependency 'gosu', '~> 0.9'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
BRICK_LENGTH = 3 # x/y-scaling of brick
|
2
|
+
BRICK_THICKNESS = 1 # y/x-scaling of brick
|
3
|
+
|
4
|
+
BRICK_STATUS_STANDING = 0
|
5
|
+
BRICK_STATUS_BEING_HELD = 1
|
6
|
+
BRICK_STATUS_FALLING = 2
|
7
|
+
|
8
|
+
BRICK_FALL_ACCELERATION = 9.8 # Earth gravity
|
9
|
+
BRICK_FALL_PRECISION = 3 # rounding precision of speed of fall
|
10
|
+
|
11
|
+
class Brick
|
12
|
+
attr_accessor :x, :y, :status
|
13
|
+
|
14
|
+
def initialize(brickyard, xx, yy, angle)
|
15
|
+
dir_path = File.dirname(__FILE__)
|
16
|
+
@image = Gosu::Image.new(dir_path + '/../../media/square.png') # TODO
|
17
|
+
@brickyard = brickyard
|
18
|
+
|
19
|
+
@x = xx
|
20
|
+
@y = yy
|
21
|
+
@angle = angle
|
22
|
+
start_falling!
|
23
|
+
end
|
24
|
+
|
25
|
+
def start_falling!
|
26
|
+
@status = BRICK_STATUS_FALLING
|
27
|
+
@falling_speed = 0
|
28
|
+
@time_of_start_of_fall = Gosu.milliseconds
|
29
|
+
end
|
30
|
+
|
31
|
+
def stop_falling!
|
32
|
+
@status = BRICK_STATUS_STANDING
|
33
|
+
@falling_speed = nil
|
34
|
+
@time_of_start_of_fall = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def update(button)
|
38
|
+
# Other states should not be needed here
|
39
|
+
# - BRICK_STATUS_STANDING does not need any updates
|
40
|
+
# - BRICK_STATUS_BEING_HELD is managed from Hook
|
41
|
+
if status == BRICK_STATUS_FALLING
|
42
|
+
# Apply falling speed to y-coords (if possible)
|
43
|
+
seconds_falling = (Gosu.milliseconds - @time_of_start_of_fall) / 1000.0
|
44
|
+
fall_accel = BRICK_FALL_ACCELERATION * seconds_falling * seconds_falling
|
45
|
+
@falling_speed = (@falling_speed + fall_accel).round(BRICK_FALL_PRECISION)
|
46
|
+
|
47
|
+
# Is there space to fall to? # TODO collide with other bricks too
|
48
|
+
if horizontal?
|
49
|
+
y_scaling = BRICK_THICKNESS
|
50
|
+
else # vertical
|
51
|
+
y_scaling = BRICK_LENGTH
|
52
|
+
end
|
53
|
+
|
54
|
+
fall_y = (@y + @falling_speed).round(1)
|
55
|
+
on_grass_y = WINDOW_HEIGHT - (GRASS_THICKNESS + y_scaling) * TILESIZE
|
56
|
+
|
57
|
+
if fall_y >= on_grass_y # stop falling
|
58
|
+
@y = on_grass_y #
|
59
|
+
stop_falling!
|
60
|
+
else # continue falling
|
61
|
+
@y = fall_y
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def draw
|
67
|
+
if horizontal?
|
68
|
+
cx = 0.5
|
69
|
+
cy = 0 # y: top
|
70
|
+
else ## vertical
|
71
|
+
cx = 0 # turned x: top
|
72
|
+
cy = 0.5
|
73
|
+
end
|
74
|
+
|
75
|
+
@image.draw_rot(@x, @y, ZITEMS, @angle,
|
76
|
+
center_x = cx, center_y = cy,
|
77
|
+
scale_x = BRICK_LENGTH, scale_y = BRICK_THICKNESS,
|
78
|
+
color = Gosu::Color::GRAY)
|
79
|
+
|
80
|
+
if $debug
|
81
|
+
coords = Gosu::Image.from_text("[#{@x}, #{@y}, #{@angle}°, S#{@status}]", LINE_HEIGHT)
|
82
|
+
coords.draw_rot(@x, @y, ZTEXT, @angle)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def rotate!
|
87
|
+
@angle = 90 - @angle
|
88
|
+
end
|
89
|
+
|
90
|
+
def top # TODO other sides
|
91
|
+
if vertical?
|
92
|
+
return 1 # @y - BRICK_LENGHT / 2
|
93
|
+
else # vertical
|
94
|
+
return 2 # @y - BRICK_THICKNESS / 2
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def horizontal?
|
99
|
+
@angle == 0
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative './../items/brick'
|
2
|
+
|
3
|
+
class Brickyard
|
4
|
+
attr_reader :bricks
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
dir_path = File.dirname(__FILE__)
|
8
|
+
@image = Gosu::Image.new(dir_path + '/../../media/square.png') # TODO
|
9
|
+
|
10
|
+
reset!
|
11
|
+
end
|
12
|
+
|
13
|
+
# Load default setup
|
14
|
+
def reset!
|
15
|
+
@x = 0.8 * MAPX * TILESIZE
|
16
|
+
@y = WINDOW_HEIGHT - GRASS_THICKNESS * TILESIZE
|
17
|
+
@bricks = [] # all (collidable) bricks
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(button)
|
21
|
+
case button
|
22
|
+
when Gosu::KB_N then
|
23
|
+
produce!
|
24
|
+
end
|
25
|
+
|
26
|
+
# Update all bricks
|
27
|
+
@bricks.each {|ii| ii.update(button)}
|
28
|
+
end
|
29
|
+
|
30
|
+
def draw
|
31
|
+
# Draw self
|
32
|
+
@image.draw_rot(@x, @y, ZITEMS, 0,
|
33
|
+
center_x = 0.5, center_y = 0, # y: top
|
34
|
+
scale_x = BRICK_THICKNESS, scale_y = GRASS_THICKNESS / 2,
|
35
|
+
color = Gosu::Color::WHITE)
|
36
|
+
|
37
|
+
# Draw all bricks
|
38
|
+
@bricks.each {|ii| ii.draw}
|
39
|
+
|
40
|
+
if $debug
|
41
|
+
info = Gosu::Image.from_text("[#{@bricks.count} brick(s)]", LINE_HEIGHT)
|
42
|
+
info.draw(@x, @y, ZTEXT)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def produce!
|
47
|
+
puts "producing" #TODO
|
48
|
+
brick_x = @x
|
49
|
+
brick_y = @y - BRICK_LENGTH * TILESIZE # just above brickyard
|
50
|
+
brick_angle = 90
|
51
|
+
|
52
|
+
new_brick = Brick.new(self, brick_x, brick_y, brick_angle)
|
53
|
+
@bricks.append(new_brick)
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
CRANE_BORDER = TILESIZE / 5 # how much space is left between crane and window
|
2
|
+
CRANE_MAST_X = 1.5 * TILESIZE # x-origin of mast
|
3
|
+
CRANE_MAST_THICKNESS = 0.7 # x-scaling of mast
|
4
|
+
CRANE_BOOM_Y = 1.5 * TILESIZE # how far from top is middle of boom
|
5
|
+
CRANE_BOOM_LENGTH = MAPX - 1 # x-scaling of boom
|
6
|
+
CRANE_BOOM_THICKNESS = 0.4 # y-scaling of boom
|
7
|
+
|
8
|
+
class Crane
|
9
|
+
def initialize()
|
10
|
+
dir_path = File.dirname(__FILE__)
|
11
|
+
@image = Gosu::Image.new(dir_path + '/../../media/square.png')
|
12
|
+
end
|
13
|
+
|
14
|
+
def draw
|
15
|
+
@image.draw(CRANE_MAST_X, CRANE_BORDER, ZCRANE,
|
16
|
+
scale_x = CRANE_MAST_THICKNESS, scale_y = MAPY - GRASS_THICKNESS,
|
17
|
+
color = Gosu::Color::YELLOW) # mast + head
|
18
|
+
@image.draw_rot(CRANE_BORDER, CRANE_BOOM_Y, ZCRANE, 0,
|
19
|
+
center_x = 0, center_y = 0.5,
|
20
|
+
scale_x = CRANE_BOOM_LENGTH, scale_y = CRANE_BOOM_THICKNESS,
|
21
|
+
color = Gosu::Color::YELLOW) # boom
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
TROLLEY_THICKNESS = 0.8 * CRANE_BOOM_THICKNESS # y-scaling of trolley
|
2
|
+
HOOK_THICKNESS = 0.15 # y-scaling of hook
|
3
|
+
HOOK_BORDER = TILESIZE / 2 # how much space is left between trolley and crane boom ends
|
4
|
+
|
5
|
+
HOOK_MIN_X = CRANE_BORDER + CRANE_MAST_X + CRANE_MAST_THICKNESS*TILESIZE + HOOK_BORDER
|
6
|
+
HOOK_MAX_X = CRANE_BOOM_LENGTH*TILESIZE - HOOK_BORDER
|
7
|
+
HOOK_MIN_Y = CRANE_BOOM_Y + (TROLLEY_THICKNESS + HOOK_THICKNESS) * TILESIZE
|
8
|
+
HOOK_MAX_Y = (MAPY - GRASS_THICKNESS) * TILESIZE
|
9
|
+
|
10
|
+
HOOK_MAGNET_X = TILESIZE / 3 # how much left/right of hook can brick be to be reachable
|
11
|
+
HOOK_MAGNET_Y = TILESIZE / 5 # how much below hook can brick be to be still reachable
|
12
|
+
|
13
|
+
class Hook
|
14
|
+
def initialize(window, brickyard, crane)
|
15
|
+
dir_path = File.dirname(__FILE__)
|
16
|
+
@image = Gosu::Image.new(dir_path + '/../../media/square.png')
|
17
|
+
@window = window
|
18
|
+
@brickyard = brickyard
|
19
|
+
@crane = crane
|
20
|
+
|
21
|
+
reset!
|
22
|
+
end
|
23
|
+
|
24
|
+
# Load default setup
|
25
|
+
def reset!
|
26
|
+
@x = CENTRE
|
27
|
+
@y = CENTRE
|
28
|
+
@angle = 0
|
29
|
+
@held = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def update(button)
|
33
|
+
case button
|
34
|
+
when Gosu::MS_LEFT then
|
35
|
+
if holding?
|
36
|
+
drop!
|
37
|
+
else
|
38
|
+
hold!
|
39
|
+
end
|
40
|
+
when Gosu::KB_R then
|
41
|
+
if holding?
|
42
|
+
@held.rotate!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# TODO directional movement instead of teleporting
|
47
|
+
@x = @window.mouse_x.to_int
|
48
|
+
@y = @window.mouse_y.to_int
|
49
|
+
|
50
|
+
# Block movement (by bricks)
|
51
|
+
# TODO
|
52
|
+
|
53
|
+
# Curtail movement (by borders of working area)
|
54
|
+
@x = [@x, HOOK_MIN_X].max
|
55
|
+
@x = [@x, HOOK_MAX_X].min
|
56
|
+
@y = [@y, HOOK_MIN_Y].max
|
57
|
+
@y = [@y, HOOK_MAX_Y].min # MAX_Y does not need to care about status of
|
58
|
+
# holding? as when TRUE the held brick should have already blocked the move
|
59
|
+
|
60
|
+
# Update held brick
|
61
|
+
if @held
|
62
|
+
@held.x = @x
|
63
|
+
@held.y = @y
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def holding?
|
68
|
+
!@held.nil?
|
69
|
+
end
|
70
|
+
|
71
|
+
def drop!
|
72
|
+
@held.start_falling!
|
73
|
+
@held = nil
|
74
|
+
end
|
75
|
+
|
76
|
+
def hold!
|
77
|
+
reachable_brick = find_reachable_brick
|
78
|
+
if reachable_brick
|
79
|
+
@held = reachable_brick
|
80
|
+
@held.stop_falling! # to be sure
|
81
|
+
@held.status = BRICK_STATUS_BEING_HELD
|
82
|
+
else
|
83
|
+
puts "no bricks nearby"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Find nearest brick under hook
|
88
|
+
def find_reachable_brick
|
89
|
+
# TODO here
|
90
|
+
reachables = @brickyard.bricks.select {
|
91
|
+
|ii| ii.x.between?(@x - HOOK_MAGNET_X, @x + HOOK_MAGNET_X)
|
92
|
+
} # brick is a bit to the left or right of hook
|
93
|
+
reachables = reachables.select {
|
94
|
+
|ii| ii.y.between?(@y, @y + HOOK_MAGNET_Y)
|
95
|
+
} # brick is at the same height or bit lower than hook
|
96
|
+
reachables[0] # if multiple in reach, pick the older
|
97
|
+
end
|
98
|
+
|
99
|
+
def draw
|
100
|
+
@image.draw_rot(@x, CRANE_BOOM_Y, ZITEMS, 0,
|
101
|
+
center_x = 0.5, center_y = 0,
|
102
|
+
scale_x = 0.75, scale_y = TROLLEY_THICKNESS,
|
103
|
+
color = Gosu::Color::BLACK) # trolley
|
104
|
+
@image.draw_rot(@x, CRANE_BOOM_Y, ZITEMS, 0,
|
105
|
+
center_x = 0.5, center_y = 0, # y: top
|
106
|
+
scale_x = 0.08, scale_y = (@y - CRANE_BOOM_Y) / TILESIZE,
|
107
|
+
color = Gosu::Color::BLACK) # cable
|
108
|
+
@image.draw_rot(@x, @y, ZITEMS, 0,
|
109
|
+
center_x = 0.5, center_y = 1, # y: bottom
|
110
|
+
scale_x = 1, scale_y = HOOK_THICKNESS,
|
111
|
+
color = Gosu::Color::BLACK) # hook itself
|
112
|
+
|
113
|
+
if $debug and not holding?
|
114
|
+
coords = Gosu::Image.from_text("[#{@x}, #{@y}, #{@angle}°]", LINE_HEIGHT)
|
115
|
+
coords.draw_rot(@x, @y, ZTEXT, @angle)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
GRASS_THICKNESS = 0.5 # y-scaling of grass
|
2
|
+
|
3
|
+
class Background
|
4
|
+
def initialize()
|
5
|
+
dir_path = File.dirname(__FILE__)
|
6
|
+
@image = Gosu::Image.new(dir_path + '/../../media/square.png')
|
7
|
+
end
|
8
|
+
|
9
|
+
def draw
|
10
|
+
@image.draw(0, 0, ZBACKGROUND,
|
11
|
+
scale_x = MAPX, scale_y = MAPY,
|
12
|
+
color = Gosu::Color::CYAN) # sky
|
13
|
+
@image.draw(0, WINDOW_HEIGHT - GRASS_THICKNESS * TILESIZE, ZBACKGROUND,
|
14
|
+
scale_x = MAPX, scale_y = GRASS_THICKNESS,
|
15
|
+
color = Gosu::Color::GREEN) # grass
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
TILESIZE = 50
|
2
|
+
MAPX = 10
|
3
|
+
MAPY = MAPX
|
4
|
+
LINE_HEIGHT = 20
|
5
|
+
|
6
|
+
require_relative './background'
|
7
|
+
require_relative './infopane'
|
8
|
+
|
9
|
+
require_relative './../items/brickyard'
|
10
|
+
require_relative './../items/crane'
|
11
|
+
require_relative './../items/hook'
|
12
|
+
|
13
|
+
WINDOW_WIDTH = MAPX * TILESIZE
|
14
|
+
WINDOW_HEIGHT = MAPY * TILESIZE
|
15
|
+
CENTRE = MAPX * TILESIZE / 2
|
16
|
+
|
17
|
+
ZBACKGROUND = 0
|
18
|
+
ZCRANE = 1
|
19
|
+
ZITEMS = 2
|
20
|
+
ZTEXT = 3
|
21
|
+
|
22
|
+
# Main window
|
23
|
+
class GameWindow < Gosu::Window
|
24
|
+
attr_reader :win
|
25
|
+
|
26
|
+
def initialize(version,
|
27
|
+
width = WINDOW_WIDTH, \
|
28
|
+
height = WINDOW_HEIGHT, \
|
29
|
+
fullscreen = false)
|
30
|
+
super(width, height, fullscreen)
|
31
|
+
|
32
|
+
# Set version name
|
33
|
+
self.caption = "Crane Construction #{version}"
|
34
|
+
$debug = false # debug messages turned off by default
|
35
|
+
reset!
|
36
|
+
|
37
|
+
@background = Background.new()
|
38
|
+
@infopane = Infopane.new(self)
|
39
|
+
|
40
|
+
@brickyard = Brickyard.new()
|
41
|
+
@crane = Crane.new()
|
42
|
+
@hook = Hook.new(self, @brickyard, @crane)
|
43
|
+
|
44
|
+
@brickyard.produce!
|
45
|
+
end
|
46
|
+
|
47
|
+
# Start processing the pushed button
|
48
|
+
def button_up(key)
|
49
|
+
case key
|
50
|
+
when Gosu::KB_ESCAPE then
|
51
|
+
self.close
|
52
|
+
when Gosu::KB_BACKSPACE then
|
53
|
+
reset
|
54
|
+
when Gosu::KB_TAB then
|
55
|
+
switch_debug!
|
56
|
+
else
|
57
|
+
@button = key
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Process given button
|
62
|
+
def update
|
63
|
+
@infopane.update
|
64
|
+
|
65
|
+
unless @won
|
66
|
+
@brickyard.update(@button)
|
67
|
+
@hook.update(@button)
|
68
|
+
check_win
|
69
|
+
end
|
70
|
+
|
71
|
+
# Stop procsesing this button
|
72
|
+
@button = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check whether player has won yet
|
76
|
+
def check_win
|
77
|
+
false # TODO
|
78
|
+
end
|
79
|
+
|
80
|
+
# Draw scene
|
81
|
+
def draw
|
82
|
+
@background.draw
|
83
|
+
@infopane.draw
|
84
|
+
|
85
|
+
@brickyard.draw
|
86
|
+
@crane.draw
|
87
|
+
@hook.draw
|
88
|
+
end
|
89
|
+
|
90
|
+
# Reset scene
|
91
|
+
def reset
|
92
|
+
reset!
|
93
|
+
@infopane.reset!
|
94
|
+
@brickyard.reset!
|
95
|
+
@hook.reset!
|
96
|
+
end
|
97
|
+
|
98
|
+
# Load default setup
|
99
|
+
def reset!
|
100
|
+
@won = false
|
101
|
+
end
|
102
|
+
|
103
|
+
# Switch debug flag
|
104
|
+
def switch_debug!
|
105
|
+
$debug = !$debug
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Infopane
|
2
|
+
attr_reader :time
|
3
|
+
|
4
|
+
def initialize(window)
|
5
|
+
@window = window
|
6
|
+
reset!
|
7
|
+
end
|
8
|
+
|
9
|
+
# Load default setup
|
10
|
+
def reset!
|
11
|
+
@starttime = Gosu.milliseconds
|
12
|
+
@time = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def update()
|
16
|
+
unless @window.win
|
17
|
+
@time = (Gosu.milliseconds - @starttime) / 1000.0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def draw
|
22
|
+
text = "#{@time}s"
|
23
|
+
|
24
|
+
if @window.win
|
25
|
+
text += "\nBackspace to restart"
|
26
|
+
end
|
27
|
+
|
28
|
+
text = Gosu::Image.from_text(
|
29
|
+
text, LINE_HEIGHT,
|
30
|
+
{:width => WINDOW_WIDTH, :align => :center}
|
31
|
+
)
|
32
|
+
text.draw(0, 0, ZTEXT)
|
33
|
+
end
|
34
|
+
end
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crane_construction
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Detros
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gosu
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: |-
|
42
|
+
Crane Construction is a simulation construction game. It
|
43
|
+
was created during the third Gosu Game Jam.
|
44
|
+
email: rasunadon@seznam.cz
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- lib/CHANGELOG.md
|
50
|
+
- lib/README.md
|
51
|
+
- lib/crane_construction.gemspec
|
52
|
+
- lib/crane_construction.rb
|
53
|
+
- lib/lib/items/brick.rb
|
54
|
+
- lib/lib/items/brickyard.rb
|
55
|
+
- lib/lib/items/crane.rb
|
56
|
+
- lib/lib/items/hook.rb
|
57
|
+
- lib/lib/user_interface/background.rb
|
58
|
+
- lib/lib/user_interface/game_window.rb
|
59
|
+
- lib/lib/user_interface/infopane.rb
|
60
|
+
- lib/media/circle.png
|
61
|
+
- lib/media/square.png
|
62
|
+
homepage: https://rasunadon.itch.io/crane-construction
|
63
|
+
licenses:
|
64
|
+
- CC-BY-SA-3.0
|
65
|
+
metadata:
|
66
|
+
source_code_uri: https://gitlab.com/rasunadon/crane_construction
|
67
|
+
bug_tracker_uri: https://gitlab.com/rasunadon/crane-construction/issues
|
68
|
+
documentation_uri: https://gitlab.com/rasunadon/crane-construction/blob/master/README.md
|
69
|
+
changelog_uri: https://gitlab.com/rasunadon/crane-construction/blob/master/CHANGELOG.md
|
70
|
+
homepage_uri: https://rasunadon.itch.io/crane-construction
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.7.6
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: A simulation construction game
|
91
|
+
test_files: []
|