-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.rb
More file actions
executable file
·97 lines (70 loc) · 1.84 KB
/
game.rb
File metadata and controls
executable file
·97 lines (70 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env ruby
# 'funworld' game
# 2006 drr
# all rights negated
require 'gosu'
require 'conf'
require 'map'
require 'idiot'
require 'dragon'
require 'ship'
require 'sagie'
class Game < Gosu::Window
def initialize
print "Enter level name: "
mapfile = STDIN.gets.chomp
#@fork = fork do
# while 1 == 1
# turn
# sleep 3
# end
# puts "fuck turn thread died"
#end
super(700, 700, false, 20)
@map = YAML::load( File.open( "#{$root_dir}/maps/#{mapfile}.fmap" ) )
@peices = []
@peices.push Dragon.new(random_spot("land"), self, "overkill")
@peices.push Dragon.new(random_spot("land"), self, "onemaN")
@peices.push Sagie.new(random_spot("land"), self, "sage")
@peices.push Ship.new(random_spot("water"), self, "Monster")
@peices.push Ship.new(random_spot("water"), self, "Swift")
@peices.push Ship.new(random_spot("water"), self, "Ike")
self.caption = "funworld woot"
@background_image = Gosu::Image.new(self, "#{$root_dir}/maps/#{mapfile}.png", true)
# console
end
def draw
update
end
def update
@background_image.draw(0, 0, 0);
#do a turn like every second
@counta ||= 1
if @counta == 1
@background_image.draw(0, 0, 0);
turn
end
@counta += 1
if @counta > (@map.tilesize * 2)
@counta = 1
end
@peices.each { |peice| @map = peice.draw(@map) }
end
def turn
@peices.each { |peice| @map = peice.turn(@map, @peices) }
@peices.each { |peice| puts "#{peice.name} at #{peice.x}, #{peice.y}" }
end
def random_spot(type)
x = 0
y = 0
tile = @map.tile(x,y)
until(tile == type)
x = rand(@map.tiles_across-1)
y = rand(@map.tiles_across-1)
tile = @map.tile(x,y)
end
return "#{x},#{y}"
end
end
game = Game.new
game.show