line-em-up 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/menu_launcher.rb +105 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bd75a1c68de409e5b0e14a35334201f8187b71e
4
- data.tar.gz: 67195a13f775a2269af0e02048b13e1c1fdbf109
3
+ metadata.gz: 07c5ee52c80e6f14468d94fcc8086c9505938464
4
+ data.tar.gz: b0739db1c6e3f4faec0b72df9a68bf573b5794d7
5
5
  SHA512:
6
- metadata.gz: 43e4cacd011d38d2ea9a7ffff79710a10a121aac65b97f59b9f7def75ac33baaf5ffda8450c1bf4af69d1882d8d7df559512ada935928a40de07ec69386c3a91
7
- data.tar.gz: 68095527adc6d54439afc6e0aeb2dedb5e4cf137b9c9cbb0d46742be9839f75a0d45b469c31336c519fa9c69030c2cd7d8ecbd443a1c03e788b36ba52f973e71
6
+ metadata.gz: df75d97d75252dd718fed343b33d23cf045439f93c17f50181c3d9118ac8532374306d6f596766e62edf64654b6f342665bab0eb31b06bc77aea809fee988528
7
+ data.tar.gz: 3ae0aba93e73f1fa98ef33fdc545a30ee7c4b199596180e9086156796683049947e2fb885bf1981c8e4b70a4f348ce7a4307620aa588a87e80efd223d5875e94
data/menu_launcher.rb ADDED
@@ -0,0 +1,105 @@
1
+ require 'gosu'
2
+
3
+ CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
4
+ MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/media"
5
+ CONFIG_FILE = "#{CURRENT_DIRECTORY}/config.txt"
6
+
7
+ Dir["#{CURRENT_DIRECTORY}/line-em-up/lib/*.rb"].each { |f| require f }
8
+ # Shouldn't need models
9
+ # Dir["#{CURRENT_DIRECTORY}/line-em-up/models/*.rb"].each { |f| require f }
10
+
11
+ require "#{CURRENT_DIRECTORY}/line-em-up/game_window.rb"
12
+
13
+ # @menu = Menu.new(self) #instantiate the menu, passing the Window in the constructor
14
+
15
+ # @menu.add_item(Gosu::Image.new("#{MEDIA_DIRECTORY}question.png"), 100, 200, 1, lambda { self.close }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}question.png", false))
16
+ # @menu.add_item(Gosu::Image.new("#{MEDIA_DIRECTORY}question.png"), 100, 250, 1, lambda { puts "something" }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}question.png", false))
17
+
18
+
19
+ class Main < Gosu::Window
20
+ def initialize
21
+ @width, @height = ResolutionSetting::RESOLUTIONS[0].split('x').collect{|s| s.to_i}
22
+ super(@width, @height, false)
23
+ @cursor = Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/cursor.png", false)
24
+ @gl_background = GLBackground.new
25
+ # x = self.width / 2 - 100
26
+ # y = self.height / 2 - 100
27
+ @center_ui_y = 0
28
+ @center_ui_x = 0
29
+ reset_center_font_ui_y
30
+ lineHeight = 50
31
+ @font = Gosu::Font.new(20)
32
+ self.caption = "A menu with Gosu"
33
+ # items = Array["exit", "additem", "item"]
34
+ # actions = Array[lambda { self.close }, lambda {
35
+ # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/item.png", false), x, y, 1, lambda { })
36
+ # y += lineHeight
37
+ # }, lambda {}]
38
+ @menu = Menu.new(self)
39
+ # for i in (0..items.size - 1)
40
+ # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/#{items[i]}.png", false), x, y, 1, actions[i], Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/#{items[i]}_hover.png", false))
41
+ # y += lineHeight
42
+ # end
43
+ exit_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/exit.png")
44
+ # puts "WIDTH HERE: #{exit_image.width}"
45
+ # 8
46
+ @menu.add_item(exit_image, ((@width / 2) - (exit_image.width / 2)), get_center_font_ui_y, 1, lambda { self.close }, exit_image)
47
+ window_height = Gosu.screen_height
48
+ @resolution_menu = ResolutionSetting.new(window_height, @width, @height, get_center_font_ui_y, CONFIG_FILE)
49
+
50
+ start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/start.png")
51
+ @game_window_width, @game_window_height, @full_screen = [nil, nil, nil]
52
+ @menu.add_item(start_image, (@width / 2) - (start_image.width / 2), get_center_font_ui_y, 1, lambda {self.close; GameWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true}) }, start_image)
53
+ debug_start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/debug_start.png")
54
+ @menu.add_item(debug_start_image, (@width / 2) - (debug_start_image.width / 2), get_center_font_ui_y, 1, lambda {self.close; GameWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true, debug: true}) }, start_image)
55
+ # @font.draw("<", width + 15, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
56
+ # @font.draw("Resolution", width / 2, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
57
+ # @font.draw(">", width - 15, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
58
+ # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/start.png", false), get_center_font_ui_x, get_center_font_ui_y, 1, lambda { self.close; GameWindow.start(nil, nil, {block_controls_until_button_up: true}) }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/start.png", false))
59
+ end
60
+
61
+ def dynamic_get_resolution_fs
62
+ @fullscreen
63
+ end
64
+
65
+ def update
66
+ @menu.update
67
+ @resolution_menu.update(self.mouse_x, self.mouse_y)
68
+
69
+ @game_window_width, @game_window_height, @fullscreen = @resolution_menu.get_resolution
70
+ @gl_background.scroll
71
+ end
72
+
73
+ def draw
74
+ @cursor.draw(self.mouse_x, self.mouse_y, 2)
75
+ # @back.draw(0,0,0)
76
+ reset_center_font_ui_y
77
+ @menu.draw
78
+ @resolution_menu.draw
79
+ @gl_background.draw(ZOrder::Background)
80
+ end
81
+
82
+ def button_down id
83
+ if id == Gosu::MsLeft then
84
+ @menu.clicked
85
+ @resolution_menu.clicked(self.mouse_x, self.mouse_y)
86
+ end
87
+ end
88
+
89
+ def get_center_font_ui_y
90
+ return_value = @center_ui_y
91
+ @center_ui_y += 50
92
+ return return_value
93
+ end
94
+
95
+ def get_center_font_ui_x
96
+ return @center_ui_x
97
+ end
98
+
99
+ def reset_center_font_ui_y
100
+ @center_ui_y = self.height / 2 - 100
101
+ @center_ui_x = self.width / 2 - 100
102
+ end
103
+ end
104
+
105
+ Main.new.show
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: line-em-up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Dana
@@ -191,6 +191,7 @@ files:
191
191
  - line-em-up/media/start.png
192
192
  - line-em-up/media/tileset.png
193
193
  - line-em-up/media/vera.ttf
194
+ - menu_launcher.rb
194
195
  homepage: https://github.com/danabr75/line-em-up
195
196
  licenses:
196
197
  - MIT