Commit 6d22799ee9a28c0cdc48116a85ce7064173680e6

Authored by Marius Hanne
1 parent 2d10b0fb5f
Exists in master

screen size

Showing 1 changed file with 15 additions and 5 deletions Side-by-side Diff

... ... @@ -5,7 +5,6 @@
5 5 require 'rubygame'
6 6  
7 7 require 'drawable'
8   -require 'animation'
9 8 require 'explosion'
10 9 require 'movable'
11 10 require 'bullet'
... ... @@ -23,7 +22,9 @@
23 22 attr_reader :screen, :queue, :clock, :objects, :player, :enemies, :level
24 23 attr_accessor :state
25 24 def initialize opts
26   - @screen = Screen.new [800, 600], 0, [HWSURFACE, DOUBLEBUF]
  25 + flags = [HWSURFACE, DOUBLEBUF]
  26 + flags << FULLSCREEN if opts[:fullscreen]
  27 + @screen = Screen.new opts[:size], 0, flags
27 28 @screen.title = "test-game"
28 29 @objects = []
29 30 @player = Player.new(self, [@screen.size[0] / 2, @screen.size[1] - 100], :fighter)
... ... @@ -32,7 +33,7 @@
32 33 @clock = Clock.new
33 34 @clock.target_framerate = 60
34 35 @keys_pressed = []
35   - @background = Surface.load(File.join(data_dir, "images", "background.png")).to_display
  36 + @background = Surface.load(File.join(data_dir, "images", "background.png")).zoom_to(@screen.size[0], @screen.size[1] * 2).to_display
36 37 @bg_pos = @background.size[1] / 2
37 38 @level = opts[:level]
38 39 @debug = opts[:debug]
... ... @@ -41,7 +42,7 @@
41 42  
42 43 def draw
43 44 @bg_pos -= 1
44   - @background.blit(@screen, [0, 0], [0, @bg_pos % @background.size[1] / 2, 800, 600])
  45 + @background.blit(@screen, [0, 0], [0, @bg_pos % @background.size[1] / 2, *@screen.size])
45 46  
46 47 @objects.each(&:blit)
47 48  
48 49  
... ... @@ -199,10 +200,19 @@
199 200  
200 201 require 'optparse'
201 202  
202   -@opts = { level: 1, debug: false }
  203 +@opts = { size: [800, 600], fullscreen: false, mute: false, level: 1, debug: false }
203 204  
204 205 OptionParser.new do |o|
205 206 o.banner = "usage: ruby #{__FILE__} [-l LEVEL] [-d]"
  207 +
  208 + o.on("-s", "--size SIZE", "Window size (800x600)") do |size|
  209 + @opts[:size] = *size.split(/x|:/).map(&:to_i)
  210 + end
  211 +
  212 + o.on("-f", "--fullscreen", "Fullscreen mode") do
  213 + @opts[:fullscreen] = true
  214 + end
  215 +
206 216 o.on("-l", "--level LEVEL", "Start at level") do |l|
207 217 @opts[:level] = l.to_i
208 218 end