gosu-test-danabr 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/gosu-test.sh +4 -0
- data/gosu-test/gosu-test.rb +487 -0
- data/gosu-test/irb_requirements.rb +11 -0
- data/gosu-test/media/BrokenPNG.png +0 -0
- data/gosu-test/media/Cursor.png +0 -0
- data/gosu-test/media/JingleBells.mp3 +0 -0
- data/gosu-test/media/JingleBells.ogg +0 -0
- data/gosu-test/media/Loop.wav +0 -0
- data/gosu-test/media/Sample.wav +0 -0
- data/gosu-test/media/SquareTexture.png +0 -0
- data/gosu-test/media/Wallpaper.png +0 -0
- data/gosu-test/media/WallpaperXXL.png +0 -0
- data/gosu-test/media/WhiteAlpha.png +0 -0
- data/gosu-test/media/audio_formats/aiff_32bit_float.aiff +0 -0
- data/gosu-test/media/audio_formats/au_16bit_pcm.au +0 -0
- data/gosu-test/media/audio_formats/caf_be_16bit_44khz.caf +0 -0
- data/gosu-test/media/audio_formats/caf_le_16bit_44khz.caf +0 -0
- data/gosu-test/media/audio_formats/caf_le_8bit_44khz.caf +0 -0
- data/gosu-test/media/audio_formats/general_midi.mid +0 -0
- data/gosu-test/media/audio_formats/impulse_tracker.it +0 -0
- data/gosu-test/media/audio_formats/mp3_128k_stereo.mp3 +0 -0
- data/gosu-test/media/audio_formats/mp3_avg_96kbit_jointstereo.mp3 +0 -0
- data/gosu-test/media/audio_formats/ogg_vorbis.ogg +0 -0
- data/gosu-test/media/audio_formats/wav_16bit_pcm.wav +0 -0
- data/gosu-test/media/audio_formats/wav_32bit_pcm.wav +0 -0
- data/gosu-test/media/audio_formats/wav_4bit_ms_adpcm.wav +0 -0
- data/gosu-test/media/beep.wav +0 -0
- data/gosu-test/media/bomb.png +0 -0
- data/gosu-test/media/bomb_original.png +0 -0
- data/gosu-test/media/bomb_pack.png +0 -0
- data/gosu-test/media/building.png +0 -0
- data/gosu-test/media/building_original.png +0 -0
- data/gosu-test/media/bullet-mini-reverse.png +0 -0
- data/gosu-test/media/bullet-mini.png +0 -0
- data/gosu-test/media/bullet.png +0 -0
- data/gosu-test/media/chain.png +0 -0
- data/gosu-test/media/chain_original.png +0 -0
- data/gosu-test/media/cptn_ruby.png +0 -0
- data/gosu-test/media/cptn_ruby_map.txt +25 -0
- data/gosu-test/media/crosshair.png +0 -0
- data/gosu-test/media/earth.png +0 -0
- data/gosu-test/media/explosion.wav +0 -0
- data/gosu-test/media/gem.png +0 -0
- data/gosu-test/media/grappling_hook.png +0 -0
- data/gosu-test/media/grappling_hook_original.png +0 -0
- data/gosu-test/media/header@2x.psd +0 -0
- data/gosu-test/media/health_original.png +0 -0
- data/gosu-test/media/health_pack_0.png +0 -0
- data/gosu-test/media/health_pack_1.png +0 -0
- data/gosu-test/media/health_pack_10.png +0 -0
- data/gosu-test/media/health_pack_11.png +0 -0
- data/gosu-test/media/health_pack_12.png +0 -0
- data/gosu-test/media/health_pack_2.png +0 -0
- data/gosu-test/media/health_pack_3.png +0 -0
- data/gosu-test/media/health_pack_4.png +0 -0
- data/gosu-test/media/health_pack_5.png +0 -0
- data/gosu-test/media/health_pack_6.png +0 -0
- data/gosu-test/media/health_pack_7.png +0 -0
- data/gosu-test/media/health_pack_8.png +0 -0
- data/gosu-test/media/health_pack_9.png +0 -0
- data/gosu-test/media/image_formats/test.jpg +0 -0
- data/gosu-test/media/image_formats/test.psd +0 -0
- data/gosu-test/media/landscape.svg +10 -0
- data/gosu-test/media/large_star.png +0 -0
- data/gosu-test/media/missile.png +0 -0
- data/gosu-test/media/missile_original.png +0 -0
- data/gosu-test/media/missile_pack.png +0 -0
- data/gosu-test/media/missile_pack_original.png +0 -0
- data/gosu-test/media/question.png +0 -0
- data/gosu-test/media/question_original.png +0 -0
- data/gosu-test/media/smoke.png +0 -0
- data/gosu-test/media/soldier.png +0 -0
- data/gosu-test/media/space.png +0 -0
- data/gosu-test/media/spaceship.png +0 -0
- data/gosu-test/media/spaceship_original.png +0 -0
- data/gosu-test/media/star.png +0 -0
- data/gosu-test/media/starfighter.bmp +0 -0
- data/gosu-test/media/starfighterv2.bmp +0 -0
- data/gosu-test/media/starfighterv4.png +0 -0
- data/gosu-test/media/tileset.png +0 -0
- data/gosu-test/media/vera.ttf +0 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 211db94e6efd53a680d3eb680fe4bb4fce97d347
|
4
|
+
data.tar.gz: d416418ff527f082097a00bf260f9982184f51c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72ccb6941a8f5cf87f99dc897ab1dfea0a828bfb788341a66457ee2ba04f567320ecc44bfc6e9625865cb9cf22d3287e030f107506bc40d8ce6b5ca5598225f5
|
7
|
+
data.tar.gz: e0d7b1455785cb7bcb8d5cec7b37b91faee9c9070ded4de74a144dfcd708f924f8985c76208c75c7247af4ced5ce74d04b78e55dc371f359051e92091ce7fd7f
|
data/bin/gosu-test.sh
ADDED
@@ -0,0 +1,487 @@
|
|
1
|
+
# A simple "Triangle Game" that allows you to move a Roguelike '@' around the
|
2
|
+
# window (and off of it). This is a working example on MacOS 10.12 as of Dec 16, 2017.
|
3
|
+
# This combines some of the Ruby2D tutorial code with keypress management
|
4
|
+
# that actually works.
|
5
|
+
#
|
6
|
+
# Keys: hjkl: movement, q: quit
|
7
|
+
#
|
8
|
+
# To run: ruby triangle-game.rb after installing the Simple2D library and Ruby2D Gem.
|
9
|
+
#
|
10
|
+
# Author: Douglas P. Fields, Jr.
|
11
|
+
# E-mail: symbolics@lisp.engineer
|
12
|
+
# Site: https://symbolics.lisp.engineer/
|
13
|
+
# Copyright 2017 Douglas P. Fields, Jr.
|
14
|
+
# License: The MIT License
|
15
|
+
|
16
|
+
# require 'gosu'
|
17
|
+
|
18
|
+
# Encoding: UTF-8
|
19
|
+
|
20
|
+
# The tutorial game over a landscape rendered with OpenGL.
|
21
|
+
# Basically shows how arbitrary OpenGL calls can be put into
|
22
|
+
# the block given to Window#gl, and that Gosu Images can be
|
23
|
+
# used as textures using the gl_tex_info call.
|
24
|
+
|
25
|
+
# require 'rubygems'
|
26
|
+
require 'gosu'
|
27
|
+
|
28
|
+
CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
|
29
|
+
MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/media"
|
30
|
+
|
31
|
+
# ONLY ENABLE FOR WINDOWS COMPILATION
|
32
|
+
# Place opengl lib in lib library
|
33
|
+
# Replace the meths list iteration with the following (added rescue blocks):
|
34
|
+
# meths.each do |mn|
|
35
|
+
# define_singleton_method(mn) do |*args,&block|
|
36
|
+
# begin
|
37
|
+
# implementation.send(mn, *args, &block)
|
38
|
+
# rescue
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
# define_method(mn) do |*args,&block|
|
42
|
+
# begin
|
43
|
+
# implementation.send(mn, *args, &block)
|
44
|
+
# rescue
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# private mn
|
48
|
+
# end
|
49
|
+
# For WINDOWS - using local lip
|
50
|
+
# require_relative 'lib/opengl.rb'
|
51
|
+
# FOR Linux\OSX - using opengl gem
|
52
|
+
require 'opengl'
|
53
|
+
|
54
|
+
Dir["#{CURRENT_DIRECTORY}/models/*.rb"].each { |f| require f }
|
55
|
+
|
56
|
+
# require_relative 'media'
|
57
|
+
# Dir["/path/to/directory/*.rb"].each {|file| require file }
|
58
|
+
#
|
59
|
+
# exit if Object.const_defined?(:Ocra) #allow ocra to create an exe without executing the entire script
|
60
|
+
|
61
|
+
|
62
|
+
WIDTH, HEIGHT = 640, 480
|
63
|
+
# WIDTH, HEIGHT = 1080, 720
|
64
|
+
|
65
|
+
module ZOrder
|
66
|
+
Background, Building, Cursor, Projectiles, SmallExplosions, BigExplosions, Pickups, Enemy, Player, UI = *0..10
|
67
|
+
end
|
68
|
+
|
69
|
+
# The only really new class here.
|
70
|
+
# Draws a scrolling, repeating texture with a randomized height map.
|
71
|
+
class GLBackground
|
72
|
+
# Height map size
|
73
|
+
POINTS_X = 7
|
74
|
+
POINTS_Y = 7
|
75
|
+
# Scrolling speed
|
76
|
+
SCROLLS_PER_STEP = 50
|
77
|
+
# TEMP USING THIS, CANNOT FIND SCROLLING SPEED
|
78
|
+
SCROLLING_SPEED = 4
|
79
|
+
|
80
|
+
def initialize
|
81
|
+
@image = Gosu::Image.new("#{MEDIA_DIRECTORY}/earth.png", :tileable => true)
|
82
|
+
@scrolls = 0
|
83
|
+
@height_map = Array.new(POINTS_Y) { Array.new(POINTS_X) { rand } }
|
84
|
+
end
|
85
|
+
|
86
|
+
def scroll
|
87
|
+
@scrolls += 1
|
88
|
+
if @scrolls == SCROLLS_PER_STEP
|
89
|
+
@scrolls = 0
|
90
|
+
@height_map.shift
|
91
|
+
@height_map.push Array.new(POINTS_X) { rand }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def draw(z)
|
96
|
+
# gl will execute the given block in a clean OpenGL environment, then reset
|
97
|
+
# everything so Gosu's rendering can take place again.
|
98
|
+
Gosu.gl(z) { exec_gl }
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
include Gl
|
104
|
+
|
105
|
+
def exec_gl
|
106
|
+
glClearColor(0.0, 0.2, 0.5, 1.0)
|
107
|
+
glClearDepth(0)
|
108
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
109
|
+
|
110
|
+
# Get the name of the OpenGL texture the Image resides on, and the
|
111
|
+
# u/v coordinates of the rect it occupies.
|
112
|
+
# gl_tex_info can return nil if the image was too large to fit onto
|
113
|
+
# a single OpenGL texture and was internally split up.
|
114
|
+
info = @image.gl_tex_info
|
115
|
+
return unless info
|
116
|
+
|
117
|
+
# Pretty straightforward OpenGL code.
|
118
|
+
|
119
|
+
glDepthFunc(GL_GEQUAL)
|
120
|
+
glEnable(GL_DEPTH_TEST)
|
121
|
+
glEnable(GL_BLEND)
|
122
|
+
|
123
|
+
glMatrixMode(GL_PROJECTION)
|
124
|
+
glLoadIdentity
|
125
|
+
glFrustum(-0.10, 0.10, -0.075, 0.075, 1, 100)
|
126
|
+
|
127
|
+
glMatrixMode(GL_MODELVIEW)
|
128
|
+
glLoadIdentity
|
129
|
+
glTranslate(0, 0, -4)
|
130
|
+
|
131
|
+
glEnable(GL_TEXTURE_2D)
|
132
|
+
glBindTexture(GL_TEXTURE_2D, info.tex_name)
|
133
|
+
|
134
|
+
offs_y = 1.0 * @scrolls / SCROLLS_PER_STEP
|
135
|
+
|
136
|
+
0.upto(POINTS_Y - 2) do |y|
|
137
|
+
0.upto(POINTS_X - 2) do |x|
|
138
|
+
glBegin(GL_TRIANGLE_STRIP)
|
139
|
+
z = @height_map[y][x]
|
140
|
+
glColor4d(1, 1, 1, z)
|
141
|
+
glTexCoord2d(info.left, info.top)
|
142
|
+
glVertex3d(-0.5 + (x - 0.0) / (POINTS_X-1), -0.5 + (y - offs_y - 0.0) / (POINTS_Y-2), z)
|
143
|
+
|
144
|
+
z = @height_map[y+1][x]
|
145
|
+
glColor4d(1, 1, 1, z)
|
146
|
+
glTexCoord2d(info.left, info.bottom)
|
147
|
+
glVertex3d(-0.5 + (x - 0.0) / (POINTS_X-1), -0.5 + (y - offs_y + 1.0) / (POINTS_Y-2), z)
|
148
|
+
|
149
|
+
z = @height_map[y][x + 1]
|
150
|
+
glColor4d(1, 1, 1, z)
|
151
|
+
glTexCoord2d(info.right, info.top)
|
152
|
+
glVertex3d(-0.5 + (x + 1.0) / (POINTS_X-1), -0.5 + (y - offs_y - 0.0) / (POINTS_Y-2), z)
|
153
|
+
|
154
|
+
z = @height_map[y+1][x + 1]
|
155
|
+
glColor4d(1, 1, 1, z)
|
156
|
+
glTexCoord2d(info.right, info.bottom)
|
157
|
+
glVertex3d(-0.5 + (x + 1.0) / (POINTS_X-1), -0.5 + (y - offs_y + 1.0) / (POINTS_Y-2), z)
|
158
|
+
glEnd
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
class OpenGLIntegration < Gosu::Window
|
166
|
+
|
167
|
+
# def button_down(id)
|
168
|
+
# puts "HERE: #{id.inspect}"
|
169
|
+
# super(id)
|
170
|
+
# end
|
171
|
+
|
172
|
+
def self.reset(window)
|
173
|
+
window = OpenGLIntegration.new.show
|
174
|
+
end
|
175
|
+
|
176
|
+
def initialize
|
177
|
+
super WIDTH, HEIGHT
|
178
|
+
|
179
|
+
@game_pause = false
|
180
|
+
@can_pause = true
|
181
|
+
@can_toggle_secondary = true
|
182
|
+
|
183
|
+
self.caption = "OpenGL Integration"
|
184
|
+
|
185
|
+
@gl_background = GLBackground.new
|
186
|
+
|
187
|
+
@player = Player.new(400, 500)
|
188
|
+
@grappling_hook = nil
|
189
|
+
|
190
|
+
# @star_anim = Gosu::Image::load_tiles("#{MEDIA_DIRECTORY}/star.png", 25, 25)
|
191
|
+
# @projectile_anim = Gosu::Image::load_tiles("#{MEDIA_DIRECTORY}/projectile.png", 25, 25)
|
192
|
+
# @projectile_anim = Gosu::Image::load_tiles("#{MEDIA_DIRECTORY}/projectile.png", 25, 25)
|
193
|
+
# @projectile_anim = Gosu::Image.new("#{MEDIA_DIRECTORY}/projectile-mini.png")
|
194
|
+
# puts "star_anim size: #{@star_anim.size}"
|
195
|
+
# puts "projectile_anim size: #{@projectile_anim.size}"
|
196
|
+
# @stars = Array.new
|
197
|
+
@buildings = Array.new
|
198
|
+
@projectiles = Array.new
|
199
|
+
@enemy_projectiles = Array.new
|
200
|
+
@pickups = Array.new
|
201
|
+
|
202
|
+
@enemies = Array.new
|
203
|
+
@enemies_random_spawn_timer = 100
|
204
|
+
@enemies_spawner_counter = 0
|
205
|
+
|
206
|
+
@font = Gosu::Font.new(20)
|
207
|
+
@max_enemies = 4
|
208
|
+
|
209
|
+
# @cursor = Gosu::Image.new(self, 'media/crosshair.png')
|
210
|
+
# @pointer = Gosu::Image.new(self,"#{MEDIA_DIRECTORY}/crosshair.png")
|
211
|
+
|
212
|
+
# pointer = Magick::Image::read("#{MEDIA_DIRECTORY}/crosshair.png").first.resize(0.3)
|
213
|
+
# @pointer = Gosu::Image.new(pointer, :tileable => true)
|
214
|
+
|
215
|
+
@pointer = Cursor.new
|
216
|
+
# @pointer = Gosu::Image.new("#{MEDIA_DIRECTORY}/bullet-mini.png")
|
217
|
+
# @px = 0
|
218
|
+
# @py = 0
|
219
|
+
@ui_y = 10
|
220
|
+
end
|
221
|
+
|
222
|
+
# def update
|
223
|
+
# @px = mouse_x # this method returns the x coordinate of the mouse
|
224
|
+
# @py = mouse_y # this method returns the y coordinate of the mouse
|
225
|
+
# end
|
226
|
+
|
227
|
+
# def draw
|
228
|
+
# @pointer.draw(@px,@py,0) # we're drawing the mouse at the current position
|
229
|
+
# end
|
230
|
+
|
231
|
+
# def needs_cursor?
|
232
|
+
# true
|
233
|
+
# end
|
234
|
+
|
235
|
+
def update
|
236
|
+
# @px = self.mouse_x # this method returns the x coordinate of the mouse
|
237
|
+
# @py = self.mouse_y # this method returns the y coordinate of the mouse
|
238
|
+
# puts "PX: #{@px} - PY: #{@py}"
|
239
|
+
|
240
|
+
if Gosu.button_down?(Gosu::KbEscape)
|
241
|
+
close!
|
242
|
+
end
|
243
|
+
|
244
|
+
# Gosu::Window#button_up
|
245
|
+
def button_up id
|
246
|
+
# super
|
247
|
+
if (id == Gosu::MS_RIGHT) && @player.is_alive
|
248
|
+
# puts "MOUSE CLICK"
|
249
|
+
# @grappling_hook = nil
|
250
|
+
@grappling_hook.deactivate if @grappling_hook
|
251
|
+
end
|
252
|
+
|
253
|
+
if (id == Gosu::KB_P)
|
254
|
+
@can_pause = true
|
255
|
+
end
|
256
|
+
if (id == Gosu::KB_TAB)
|
257
|
+
# puts "TAB UP"
|
258
|
+
@can_toggle_secondary = true
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
|
263
|
+
if Gosu.button_down?(Gosu::KB_M)
|
264
|
+
OpenGLIntegration.reset(self)
|
265
|
+
end
|
266
|
+
|
267
|
+
if Gosu.button_down?(Gosu::KB_P) && @can_pause
|
268
|
+
@can_pause = false
|
269
|
+
# puts "GAME PAUSE: #{@game_pause}"
|
270
|
+
@game_pause = !@game_pause
|
271
|
+
end
|
272
|
+
|
273
|
+
if Gosu.button_down?(Gosu::KB_TAB) && @can_toggle_secondary
|
274
|
+
# puts "TAB HERE"
|
275
|
+
@can_toggle_secondary = false
|
276
|
+
@player.toggle_secondary
|
277
|
+
end
|
278
|
+
|
279
|
+
if @player.is_alive && !@game_pause
|
280
|
+
@player.update
|
281
|
+
@player.move_left if Gosu.button_down?(Gosu::KB_LEFT) || Gosu.button_down?(Gosu::GP_LEFT) || Gosu.button_down?(Gosu::KB_A)
|
282
|
+
@player.move_right if Gosu.button_down?(Gosu::KB_RIGHT) || Gosu.button_down?(Gosu::GP_RIGHT) || Gosu.button_down?(Gosu::KB_D)
|
283
|
+
@player.accelerate if Gosu.button_down?(Gosu::KB_UP) || Gosu.button_down?(Gosu::GP_UP) || Gosu.button_down?(Gosu::KB_W)
|
284
|
+
@player.brake if Gosu.button_down?(Gosu::KB_DOWN) || Gosu.button_down?(Gosu::GP_DOWN) || Gosu.button_down?(Gosu::KB_S)
|
285
|
+
|
286
|
+
if Gosu.button_down?(Gosu::MS_RIGHT)
|
287
|
+
if @grappling_hook == nil
|
288
|
+
@grappling_hook = GrapplingHook.new(@player)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
# if Gosu.button_down?(Gosu::MS_LEFT)
|
296
|
+
# # puts "MOUSE CLICK"
|
297
|
+
# if @player.secondary_cooldown_wait <= 0 && @player.rockets > 0
|
298
|
+
# results = @player.secondary_attack(self.mouse_x, self.mouse_y)
|
299
|
+
# projectiles = results[:projectiles]
|
300
|
+
# cooldown = results[:cooldown]
|
301
|
+
# @player.secondary_cooldown_wait = cooldown.to_f.fdiv(@player.attack_speed)
|
302
|
+
|
303
|
+
# projectiles.each do |projectile|
|
304
|
+
# @player.rockets -= 1
|
305
|
+
# @projectiles.push(projectile)
|
306
|
+
# end
|
307
|
+
# end
|
308
|
+
# end
|
309
|
+
|
310
|
+
if Gosu.button_down?(Gosu::MS_LEFT)
|
311
|
+
# puts "MOUSE CLICK"
|
312
|
+
@projectiles = @projectiles + @player.trigger_secondary_attack(self.mouse_x, self.mouse_y)
|
313
|
+
end
|
314
|
+
|
315
|
+
if Gosu.button_down?(Gosu::KB_SPACE)
|
316
|
+
if @player.cooldown_wait <= 0
|
317
|
+
results = @player.attack(self.mouse_x, self.mouse_y)
|
318
|
+
projectiles = results[:projectiles]
|
319
|
+
cooldown = results[:cooldown]
|
320
|
+
@player.cooldown_wait = cooldown.to_f.fdiv(@player.attack_speed)
|
321
|
+
|
322
|
+
projectiles.each do |projectile|
|
323
|
+
@projectiles.push(projectile)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
# @player.collect_stars(@stars)
|
330
|
+
@player.collect_pickups(@pickups)
|
331
|
+
|
332
|
+
@enemy_projectiles.each do |projectile|
|
333
|
+
# projectile.hit_stars(@stars)
|
334
|
+
projectile.hit_object(@player)
|
335
|
+
# results =
|
336
|
+
# if hit_player > 0
|
337
|
+
# # puts "hit_player: #{hit_player}"
|
338
|
+
# @player.health -= hit_player
|
339
|
+
# end
|
340
|
+
end
|
341
|
+
|
342
|
+
|
343
|
+
@grappling_hook.collect_pickups(@player, @pickups) if @grappling_hook && @grappling_hook.active
|
344
|
+
end
|
345
|
+
|
346
|
+
if !@game_pause
|
347
|
+
|
348
|
+
@projectiles.each do |projectile|
|
349
|
+
results = projectile.hit_objects([@enemies, @buildings])
|
350
|
+
# puts "RESULTS HERE: #{results}"
|
351
|
+
@pickups = @pickups + results[:drops]
|
352
|
+
@player.score += results[:point_value]
|
353
|
+
end
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
# @stars.reject! { |star| !star.update }
|
359
|
+
@buildings.reject! { |building| !building.update }
|
360
|
+
|
361
|
+
if @player.is_alive && @grappling_hook
|
362
|
+
grap_result = @grappling_hook.update(self.mouse_x, self.mouse_y, @player)
|
363
|
+
# puts "Setting grap to nil - #{grap_result}" if !grap_result
|
364
|
+
@grappling_hook = nil if !grap_result
|
365
|
+
end
|
366
|
+
|
367
|
+
# @buildings.reject! do |building|
|
368
|
+
# results = building.update
|
369
|
+
# (results[:drops] || []).each do |drop|
|
370
|
+
# @pickups << drop
|
371
|
+
# end
|
372
|
+
# !results[:update]
|
373
|
+
# end
|
374
|
+
|
375
|
+
@pickups.reject! { |pickup| !pickup.update(self.mouse_x, self.mouse_y) }
|
376
|
+
|
377
|
+
@projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y) }
|
378
|
+
|
379
|
+
@enemy_projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y) }
|
380
|
+
@enemies.reject! { |enemy| !enemy.update(@player) }
|
381
|
+
|
382
|
+
|
383
|
+
@gl_background.scroll
|
384
|
+
|
385
|
+
# @stars.push(Star.new()) if rand(75) == 0
|
386
|
+
|
387
|
+
# @buildings.push(Building.new()) if rand(500) == 0
|
388
|
+
@buildings.push(Building.new()) if rand(100) == 0
|
389
|
+
|
390
|
+
|
391
|
+
# @enemies.push(EnemyPlayer.new()) if @enemies.count == 0
|
392
|
+
if @player.is_alive && rand(@enemies_random_spawn_timer) == 0 && @enemies.count <= @max_enemies
|
393
|
+
(0..@enemies_spawner_counter).each do |count|
|
394
|
+
@enemies.push(EnemyPlayer.new())
|
395
|
+
end
|
396
|
+
end
|
397
|
+
if @player.time_alive % 500 == 0
|
398
|
+
@max_enemies += 1
|
399
|
+
end
|
400
|
+
if @player.time_alive % 1000 == 0 && @enemies_random_spawn_timer > 5
|
401
|
+
@enemies_random_spawn_timer -= 5
|
402
|
+
end
|
403
|
+
if @player.time_alive % 5000 == 0
|
404
|
+
@enemies_spawner_counter += 1
|
405
|
+
end
|
406
|
+
|
407
|
+
if @player.time_alive % 1000 == 0 && @player.time_alive > 0
|
408
|
+
@player.score += 100
|
409
|
+
end
|
410
|
+
|
411
|
+
|
412
|
+
# Move to enemy mehtods
|
413
|
+
@enemies.each do |enemy|
|
414
|
+
enemy.cooldown_wait -= 1 if enemy.cooldown_wait > 0
|
415
|
+
if enemy.cooldown_wait <= 0
|
416
|
+
results = enemy.attack
|
417
|
+
projectiles = results[:projectiles]
|
418
|
+
cooldown = results[:cooldown]
|
419
|
+
enemy.cooldown_wait = cooldown.to_f.fdiv(enemy.attack_speed)
|
420
|
+
|
421
|
+
projectiles.each do |projectile|
|
422
|
+
@enemy_projectiles.push(projectile)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
# def scroll
|
430
|
+
# @buildings.reject! { |building| !building.update }
|
431
|
+
# end
|
432
|
+
|
433
|
+
def draw
|
434
|
+
@pointer.draw(self.mouse_x, self.mouse_y) if @grappling_hook.nil? || !@grappling_hook.active
|
435
|
+
|
436
|
+
@player.draw if @player.is_alive
|
437
|
+
@grappling_hook.draw(@player) if @player.is_alive && @grappling_hook
|
438
|
+
@font.draw("You are dead!", WIDTH / 2 - 50, HEIGHT / 2 - 55, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if !@player.is_alive
|
439
|
+
@font.draw("Press ESC to quit", WIDTH / 2 - 50, HEIGHT / 2 - 40, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if !@player.is_alive
|
440
|
+
@font.draw("Press M to Restart", WIDTH / 2 - 50, HEIGHT / 2 - 25, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if !@player.is_alive
|
441
|
+
@font.draw("Paused", WIDTH / 2 - 50, HEIGHT / 2 - 25, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @game_pause
|
442
|
+
@enemies.each { |enemy| enemy.draw }
|
443
|
+
@projectiles.each { |projectile| projectile.draw() }
|
444
|
+
@enemy_projectiles.each { |projectile| projectile.draw() }
|
445
|
+
# @stars.each { |star| star.draw }
|
446
|
+
@pickups.each { |pickup| pickup.draw }
|
447
|
+
@buildings.each { |building| building.draw }
|
448
|
+
@font.draw("Score: #{@player.score}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
449
|
+
# @font.draw("Attack Speed: #{@player.attack_speed.round(2)}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
450
|
+
@font.draw("Health: #{@player.health}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
451
|
+
@font.draw("Armor: #{@player.armor}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
452
|
+
# @font.draw("Rockets: #{@player.rockets}", 10, 70, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.secondary_weapon == 'missile'
|
453
|
+
# @font.draw("Bombs: #{@player.bombs}", 10, 70, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.secondary_weapon == 'bomb'
|
454
|
+
@font.draw("Weapon: #{@player.get_secondary_name}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
455
|
+
@font.draw("Rockets: #{@player.rockets}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
456
|
+
@font.draw("Bombs: #{@player.bombs}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.bombs > 0
|
457
|
+
@font.draw("Time Alive: #{@player.time_alive}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
458
|
+
@font.draw("Level: #{@enemies_spawner_counter + 1}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
|
459
|
+
@gl_background.draw(ZOrder::Background)
|
460
|
+
reset_font_ui_y
|
461
|
+
end
|
462
|
+
|
463
|
+
def get_font_ui_y
|
464
|
+
return_value = @ui_y
|
465
|
+
@ui_y += 15
|
466
|
+
return return_value
|
467
|
+
end
|
468
|
+
def reset_font_ui_y
|
469
|
+
@ui_y = 10
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
OpenGLIntegration.new.show if __FILE__ == $0
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# irb -r ./irb_requirements.rb
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'gosu'
|
5
|
+
require 'gl'
|
6
|
+
# require 'rmagick'
|
7
|
+
# require 'geometry'
|
8
|
+
# require_relative 'star.rb'
|
9
|
+
# require_relative 'bullet.rb'
|
10
|
+
# require_relative 'player.rb'
|
11
|
+
# require_relative 'enemy_player.rb'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#....................................................#
|
2
|
+
#....................................................#
|
3
|
+
#.............xx......x.x............................#
|
4
|
+
#............x..x....................................#
|
5
|
+
#x....x...x..x.......#####..xxx....................x.#
|
6
|
+
#.x.........................xxx.........##.........x.#
|
7
|
+
#...............""..........###...##..........##.....#
|
8
|
+
#..##..###..##..##...................................#
|
9
|
+
#........................................xx........###
|
10
|
+
#.............................###....................#
|
11
|
+
##....##.............................................#
|
12
|
+
#....................##....##......##....##....##....#
|
13
|
+
#.................................................x..#
|
14
|
+
#...x....##....##.......x...x.....................x..#
|
15
|
+
#.....x...............x...x...x...................x..#
|
16
|
+
#......x...##.....##.................................#
|
17
|
+
#.......x.........................................#..#
|
18
|
+
#...........##........#...#...#..#.......x...........#
|
19
|
+
#...#................................................#
|
20
|
+
#....."""".................x.......#..#####...###....#
|
21
|
+
#x....#......................##......................#
|
22
|
+
#"""""#.....#.....x..................#...............#
|
23
|
+
##xxxx......#........................................#
|
24
|
+
##xxxx...#####............."...""""".................#
|
25
|
+
######"""#############################################
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" clip-rule="evenodd" stroke-miterlimit="10" viewBox="0 0 850.39 637.80">
|
3
|
+
<desc>SVG generated by Lineform</desc>
|
4
|
+
<defs/>
|
5
|
+
<g>
|
6
|
+
<rect width="940.00" height="734.00" x="-25.50" y="-55.50" fill="#5FB7FF" stroke="#000000" stroke-width="2.20"/>
|
7
|
+
<path d="M 223.50 49.00 C 171.16 49.00 118.84 59.51 78.91 80.50 C -0.96 122.48 -0.96 190.52 78.91 232.50 C 134.24 261.59 213.37 270.50 283.34 259.28 C 350.32 290.78 452.18 289.47 516.06 255.19 C 582.65 219.45 582.65 161.55 516.06 125.81 C 482.95 108.04 439.59 99.12 396.19 99.03 C 388.26 92.46 378.99 86.23 368.09 80.50 C 328.16 59.51 275.84 49.00 223.50 49.00 Z M 223.50 49.00 " fill="#FFFFFF" stroke="#BFBFBF" stroke-width="6.00"/>
|
8
|
+
<path d="M 735.48 183.00 C 699.52 183.00 663.55 187.05 636.11 195.16 C 607.54 203.59 593.99 214.76 595.17 225.81 C 561.74 227.76 529.60 233.37 503.83 242.72 C 438.71 266.35 438.71 304.65 503.83 328.28 C 568.96 351.91 674.56 351.91 739.69 328.28 C 787.65 310.88 800.17 285.50 777.48 263.91 C 798.41 261.97 818.28 258.74 834.86 253.84 C 889.73 237.64 889.73 211.36 834.86 195.16 C 807.42 187.05 771.44 183.00 735.48 183.00 Z M 735.48 183.00 " fill="#FFFFFF" stroke="#BFBFBF" stroke-width="6.00"/>
|
9
|
+
</g>
|
10
|
+
</svg>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gosu-test-danabr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Dana
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ocra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.10
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.10
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gosu
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.13.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.13.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: danabr75-opengl
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.0
|
55
|
+
description: A simple gosu test
|
56
|
+
email: benrdana@gmail.com
|
57
|
+
executables:
|
58
|
+
- gosu-test.sh
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- bin/gosu-test.sh
|
63
|
+
- gosu-test/gosu-test.rb
|
64
|
+
- gosu-test/irb_requirements.rb
|
65
|
+
- gosu-test/media/BrokenPNG.png
|
66
|
+
- gosu-test/media/Cursor.png
|
67
|
+
- gosu-test/media/JingleBells.mp3
|
68
|
+
- gosu-test/media/JingleBells.ogg
|
69
|
+
- gosu-test/media/Loop.wav
|
70
|
+
- gosu-test/media/Sample.wav
|
71
|
+
- gosu-test/media/SquareTexture.png
|
72
|
+
- gosu-test/media/Wallpaper.png
|
73
|
+
- gosu-test/media/WallpaperXXL.png
|
74
|
+
- gosu-test/media/WhiteAlpha.png
|
75
|
+
- gosu-test/media/audio_formats/aiff_32bit_float.aiff
|
76
|
+
- gosu-test/media/audio_formats/au_16bit_pcm.au
|
77
|
+
- gosu-test/media/audio_formats/caf_be_16bit_44khz.caf
|
78
|
+
- gosu-test/media/audio_formats/caf_le_16bit_44khz.caf
|
79
|
+
- gosu-test/media/audio_formats/caf_le_8bit_44khz.caf
|
80
|
+
- gosu-test/media/audio_formats/general_midi.mid
|
81
|
+
- gosu-test/media/audio_formats/impulse_tracker.it
|
82
|
+
- gosu-test/media/audio_formats/mp3_128k_stereo.mp3
|
83
|
+
- gosu-test/media/audio_formats/mp3_avg_96kbit_jointstereo.mp3
|
84
|
+
- gosu-test/media/audio_formats/ogg_vorbis.ogg
|
85
|
+
- gosu-test/media/audio_formats/wav_16bit_pcm.wav
|
86
|
+
- gosu-test/media/audio_formats/wav_32bit_pcm.wav
|
87
|
+
- gosu-test/media/audio_formats/wav_4bit_ms_adpcm.wav
|
88
|
+
- gosu-test/media/beep.wav
|
89
|
+
- gosu-test/media/bomb.png
|
90
|
+
- gosu-test/media/bomb_original.png
|
91
|
+
- gosu-test/media/bomb_pack.png
|
92
|
+
- gosu-test/media/building.png
|
93
|
+
- gosu-test/media/building_original.png
|
94
|
+
- gosu-test/media/bullet-mini-reverse.png
|
95
|
+
- gosu-test/media/bullet-mini.png
|
96
|
+
- gosu-test/media/bullet.png
|
97
|
+
- gosu-test/media/chain.png
|
98
|
+
- gosu-test/media/chain_original.png
|
99
|
+
- gosu-test/media/cptn_ruby.png
|
100
|
+
- gosu-test/media/cptn_ruby_map.txt
|
101
|
+
- gosu-test/media/crosshair.png
|
102
|
+
- gosu-test/media/earth.png
|
103
|
+
- gosu-test/media/explosion.wav
|
104
|
+
- gosu-test/media/gem.png
|
105
|
+
- gosu-test/media/grappling_hook.png
|
106
|
+
- gosu-test/media/grappling_hook_original.png
|
107
|
+
- gosu-test/media/header@2x.psd
|
108
|
+
- gosu-test/media/health_original.png
|
109
|
+
- gosu-test/media/health_pack_0.png
|
110
|
+
- gosu-test/media/health_pack_1.png
|
111
|
+
- gosu-test/media/health_pack_10.png
|
112
|
+
- gosu-test/media/health_pack_11.png
|
113
|
+
- gosu-test/media/health_pack_12.png
|
114
|
+
- gosu-test/media/health_pack_2.png
|
115
|
+
- gosu-test/media/health_pack_3.png
|
116
|
+
- gosu-test/media/health_pack_4.png
|
117
|
+
- gosu-test/media/health_pack_5.png
|
118
|
+
- gosu-test/media/health_pack_6.png
|
119
|
+
- gosu-test/media/health_pack_7.png
|
120
|
+
- gosu-test/media/health_pack_8.png
|
121
|
+
- gosu-test/media/health_pack_9.png
|
122
|
+
- gosu-test/media/image_formats/test.jpg
|
123
|
+
- gosu-test/media/image_formats/test.psd
|
124
|
+
- gosu-test/media/landscape.svg
|
125
|
+
- gosu-test/media/large_star.png
|
126
|
+
- gosu-test/media/missile.png
|
127
|
+
- gosu-test/media/missile_original.png
|
128
|
+
- gosu-test/media/missile_pack.png
|
129
|
+
- gosu-test/media/missile_pack_original.png
|
130
|
+
- gosu-test/media/question.png
|
131
|
+
- gosu-test/media/question_original.png
|
132
|
+
- gosu-test/media/smoke.png
|
133
|
+
- gosu-test/media/soldier.png
|
134
|
+
- gosu-test/media/space.png
|
135
|
+
- gosu-test/media/spaceship.png
|
136
|
+
- gosu-test/media/spaceship_original.png
|
137
|
+
- gosu-test/media/star.png
|
138
|
+
- gosu-test/media/starfighter.bmp
|
139
|
+
- gosu-test/media/starfighterv2.bmp
|
140
|
+
- gosu-test/media/starfighterv4.png
|
141
|
+
- gosu-test/media/tileset.png
|
142
|
+
- gosu-test/media/vera.ttf
|
143
|
+
homepage: http://rubygems.org/gems/hola
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.6.11
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Hola!
|
167
|
+
test_files: []
|