Guest User

Untitled

a guest
Jul 13th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.47 KB | None | 0 0
  1. # Arthur's Adventures
  2.  
  3. begin
  4. # In case you use Gosu via rubygems.
  5. require 'rubygems'
  6. rescue LoadError
  7. # In case you don't.
  8. end
  9.  
  10. require 'items'
  11. require 'arthur'
  12. require 'map'
  13. require 'gosu'
  14. include Gosu
  15.  
  16. module Tiles
  17. Grass = 0
  18. Earth = 1
  19. Bstone = 2
  20. Bstoneg = 3
  21. Ystone = 4
  22. Ystoneg = 5
  23. Rstoneg = 6
  24. Rstone = 7
  25. Earthw1 = 8
  26. Ystonew1 = 9
  27. Rstonew1 = 10
  28. Earthw2 = 11
  29. Earthw3 = 12
  30. Earthw4 = 13
  31. Ystonew2 = 14
  32. Ystonew3 = 15
  33. Ystonew4 = 16
  34. Rstonew2 = 17
  35. Rstonew3 = 18
  36. Rstonew4 = 19
  37. Istonew2 = 20
  38. Istonew3 = 21
  39. Istonew4 = 22
  40. Istonew1 = 23
  41. end
  42.  
  43.  
  44. class Player
  45. # Magic numbers considered harmful! This is the height of the
  46. # player as used for collision detection.
  47. HEIGHT = 14
  48.  
  49. attr_reader :x, :y, :dead
  50.  
  51. def initialize(window, x, y, color)
  52. # Only load the images once for all instances of this class.
  53. @@images ||= Gosu::Image.load_tiles(window, "data/Soldier.png", 40, 50, false)
  54.  
  55. @window, @x, @y, @color = window, x, y, color
  56. @vy = 0
  57.  
  58. # -1: left, +1: right
  59. @dir = -1
  60.  
  61. # Aiming angle.
  62. @angle = 45
  63. end
  64.  
  65. def draw
  66.  
  67. end
  68.  
  69. def update
  70. # First, assume that no walking happened this frame.
  71. @show_walk_anim = false
  72.  
  73. # Gravity.
  74. @vy += 1
  75.  
  76. if @vy > 1 then
  77. # Move upwards until hitting something.
  78. @vy.times do
  79. if @window.map.solid?(x, y + 1)
  80. @vy = 0
  81. break
  82. else
  83. @y += 1
  84. end
  85. end
  86. else
  87. # Move downwards until hitting something.
  88. (-@vy).times do
  89. if @window.map.solid?(x, y - HEIGHT - 1)
  90. @vy = 0
  91. break
  92. else
  93. @y -= 1
  94. end
  95. end
  96. end
  97.  
  98. # Soldiers are never deleted (they may die, though, but that is a different
  99. # concept).
  100. true
  101. end
  102.  
  103. def aim_up
  104. @angle -= 2 unless @angle < 10
  105. end
  106.  
  107. def aim_down
  108. @angle += 2 unless @angle > 170
  109. end
  110.  
  111.  
  112. def shootleft
  113. #@window.objects << Missile.new(@window, $x + 10 * @dir, $y - 10, @angle * @dir)
  114. @window.objects << Missile.new(@window, $scrx +5 , $scry-35, @angle * -1)
  115.  
  116. end
  117.  
  118. def shootright
  119. #@window.objects << Missile.new(@window, $x + 10 * @dir, $y - 10, @angle * @dir)
  120. @window.objects << Missile.new(@window, $scrx -55, $scry-35, @angle * +1)
  121.  
  122. end
  123.  
  124. def hit_by?(missile)
  125. if Gosu::distance(missile.x, missile.y, x, y) < 30 then
  126. # Was hit :(
  127. @dead = true
  128. return true
  129. else
  130. return false
  131. end
  132. end
  133. end
  134.  
  135. # Implements the same interface as Player, except it'S a missile!
  136.  
  137. class Missile
  138. attr_reader :x, :y, :vx, :vy
  139.  
  140. def initialize(window, x, y, angle)
  141. # All missile instances use the same sound.
  142. @@explosion_sound ||= Gosu::Sample.new(window, "data/Explosion.wav")
  143. @dagger1l = Image.new(window, "data/items/dagger1-2l.png", true)
  144. @dagger1r = Image.new(window, "data/items/dagger1-2r.png", true)
  145.  
  146. # Horizontal/vertical velocity.
  147. @vx, @vy = Gosu::offset_x(angle, 20).to_i, Gosu::offset_y(angle, 20).to_i
  148.  
  149. @window, @x, @y = window, x + @vx, y + @vy
  150. end
  151.  
  152. def update
  153. # Movement, gravity
  154. @x += @vx
  155. #@y += @vy
  156. #@vy += 1
  157. # Hit anything?
  158.  
  159. end
  160.  
  161. def draw
  162. # Just draw a small quad.
  163. #@window.draw_quad(x-2, y-2, 0xff800000, x+2, y-2, 0xff800000,
  164. # x-2, y+2, 0xff800000, x+2, y+2, 0xff800000, 0)
  165. if $dir == :left then
  166. @dagger1l.draw(x , y, 0, 1,1)
  167. else
  168. @dagger1r.draw(x , y, 0, 1,1)
  169. end
  170.  
  171.  
  172. #@dagger1.draw(x , y, 0, 1,1)
  173. end
  174.  
  175. def hit_by?(missile)
  176. # Missiles can't be hit by other missiles!
  177. false
  178. end
  179. end
  180.  
  181. class Particle
  182. def initialize(window, x, y)
  183. # All Particle instances use the same image
  184. @@image ||= Gosu::Image.new(window, 'data/Smoke.png', false)
  185.  
  186. @x, @y = x, y
  187. @color = Gosu::Color.new(255, 255, 255, 255)
  188. end
  189.  
  190. def update
  191. @y -= 5
  192. @x = @x - 1 + rand(3)
  193. @color.alpha -= 5
  194.  
  195. # Remove if faded completely.
  196. @color.alpha > 0
  197. end
  198.  
  199. def draw
  200. #@@image.draw(@x - 25, @y - 25, 0, 1, 1, @color)
  201. end
  202.  
  203. def hit_by?(missile)
  204. # Smoke can't be hit!
  205. false
  206. end
  207. end
  208.  
  209.  
  210.  
  211. class Game < Window
  212. attr_reader :map, :gamexres, :gameyres,:gamemode,:loadedstuff,
  213. :titlescreeniconpos,:pausescreeniconpos,:htpgpagenum,:lastgamemode,:shopscreeniconpos,:selectedgroup,:rannum, :objects,
  214. :scrx,:scry,:scry1
  215.  
  216. def initialize
  217. @gamexres,@gameyres = 1280,800
  218. super(@gamexres,@gameyres, true)
  219. #@gamexres,@gameyres = 1270,790
  220. #super(@gamexres,@gameyres, false)
  221. @rannum = 1
  222. $lastgamemode = 1
  223. $gamemode = 1
  224. $loadedstuff = 0
  225. $selectedgroup = 1
  226. $scrx,$scry,$scry1 = 0,0,0
  227.  
  228. @players = [Player.new(self, 200, 40, 0xff308000)]
  229. @objects = @players.dup
  230.  
  231. self.caption = "Arthur's Adventures V0.4"
  232. @font = Gosu::Font.new(self, Gosu::default_font_name, 20)
  233. @fontsmall = Gosu::Font.new(self, Gosu::default_font_name, 14)
  234. @titlefont1 = Gosu::Font.new(self, Gosu::default_font_name, 45)
  235. @creditsfont = Gosu::Font.new(self, Gosu::default_font_name, 30)
  236. @titlescreenimage = Image.new(self, "data/backgrounds/titlescreenv5.png", true)
  237. @introimage = Image.new(self, "data/backgrounds/intro.png", true)
  238. @pausescreenimage = Image.new(self, "data/backgrounds/pausescreen1.png", true)
  239. @shopscreenimage = Image.new(self, "data/backgrounds/shopscreen1.png", true)
  240. @howtoplayguidepage1 = Image.new(self, "data/backgrounds/htpgp1.png", true)
  241. @howtoplayguidepage2 = Image.new(self, "data/backgrounds/htpgp2.png", true)
  242. @howtoplayguidepage3 = Image.new(self, "data/backgrounds/htpgp3.png", true)
  243. @howtoplayguidepage4 = Image.new(self, "data/backgrounds/htpgp4.png", true)
  244. @creditspage = Image.new(self, "data/backgrounds/credits.png", true)
  245. @menuicon = Image.new(self, "data/items/dagger4-2.png", true)
  246.  
  247.  
  248.  
  249. @menumovesound = Gosu::Sample.new(self, "data/sfx/menumovesound.wav")
  250. @menupressbuttonsound = Gosu::Sample.new(self, "data/sfx/bpress.wav")
  251. @pausebuttonsound = Gosu::Sample.new(self, "data/sfx/pausesound.wav")
  252. @unpausebuttonsound = Gosu::Sample.new(self, "data/sfx/unpausesound.wav")
  253. @errorsound = Gosu::Sample.new(self, "data/sfx/errorsound.wav")
  254. @buyitemsound = Gosu::Sample.new(self, "data/sfx/buyitem1.wav")
  255.  
  256. $hitsound = Gosu::Sample.new(self, "data/sfx/errorsound.wav")
  257.  
  258. $titlescreeniconpos = 1
  259. $pausescreeniconpos = 1
  260. $htpgpagenum = 1
  261. $shopscreeniconpos = 1
  262. @fps_check = FPSCounter.new()
  263. @cptn = Arthur.new(self, 400, 100)
  264.  
  265.  
  266.  
  267.  
  268. @hpbarcolor = Gosu::Color.new(0xff000000)
  269. @hpbarcolor.red = 255
  270. @hpbarcolor.green = 0
  271. @hpbarcolor.blue = 0
  272.  
  273. @hpbarcolor2 = Gosu::Color.new(0xff000000)
  274. @hpbarcolor2.red = 248
  275. @hpbarcolor2.green = 251
  276. @hpbarcolor2.blue = 4
  277.  
  278. @mpbarcolor = Gosu::Color.new(0xff000000)
  279. @mpbarcolor.red = 0
  280. @mpbarcolor.green = 0
  281. @mpbarcolor.blue = 255
  282.  
  283. @mpbarcolor2 = Gosu::Color.new(0xff000000)
  284. @mpbarcolor2.red = 9
  285. @mpbarcolor2.green = 198
  286. @mpbarcolor2.blue = 253
  287.  
  288.  
  289. $titlescreenmusicogg.volume = 0.15
  290. $normalareamusicogg.volume = 0.15
  291. $titlescreenmusicogg.play(looping = true)
  292. # Scrolling is stored as the position of the top left corner of the screen.
  293. @screen_x = @screen_y = 0
  294. end
  295.  
  296. def changemusic
  297. if $currentarea == 1 then $normalareamusicogg.play(looping = true) end
  298. if $currentarea == 2 then $normalareamusicogg.play(looping = true) end
  299. if $currentarea == 3 then $normalareamusicogg.play(looping = true) end
  300. if $currentarea == 4 then $normalareamusicogg.play(looping = true) end
  301. if $currentarea == 5 then $normalareamusicogg.play(looping = true) end
  302. if $currentarea == 6 then $iceareamusicogg.play(looping = true) end
  303. if $currentarea == 7 then $fireareamusicogg.play(looping = true) end
  304. if $currentarea == 8 then $normalareamusicogg.play(looping = true) end
  305. if $currentarea == 9 then $evilareamusicogg.play(looping = true) end
  306.  
  307. end
  308.  
  309. def pausemusic
  310. if $currentarea == 1 then $normalareamusicogg.pause end
  311. if $currentarea == 2 then $normalareamusicogg.pause end
  312. if $currentarea == 3 then $normalareamusicogg.pause end
  313. if $currentarea == 4 then $normalareamusicogg.pause end
  314. if $currentarea == 5 then $normalareamusicogg.pause end
  315. if $currentarea == 6 then $iceareamusicogg.pause end
  316. if $currentarea == 7 then $fireareamusicogg.pause end
  317. if $currentarea == 8 then $normalareamusicogg.pause end
  318. if $currentarea == 9 then $evilareamusicogg.pause end
  319. if $currentarea == 10 then $fireareamusicogg.pause end
  320. if $currentarea == 11 then $iceareamusicogg.pause end
  321. if $currentarea == 12 then $lightningareamusicogg.pause end
  322. if $currentarea == 13 then $groundareamusicogg.pause end
  323. if $currentarea == 15 then $evilareamusicogg.pause end
  324.  
  325.  
  326. end
  327. def update
  328. $touchingshop = 0
  329.  
  330.  
  331. if $gamemode == 2 then
  332.  
  333. @waiting &&= !@objects.grep(Missile).empty?
  334.  
  335. @objects.reject! { |o| o.update == false }
  336.  
  337. move_x = 0
  338. move_x -= 5 and @rannum = (rand 100)+1 if button_down? Button::KbLeft
  339.  
  340. move_x -= 5 and @rannum = (rand 100)+1 if button_down? Button::GpLeft
  341. move_x += 5 and @rannum = (rand 100)+1 if button_down? Button::KbRight
  342. move_x += 5 and @rannum = (rand 100)+1 if button_down? Button::GpRight
  343.  
  344. #if @rannum == 100 then @menumovesound.play end
  345.  
  346. @cptn.update(move_x)
  347. @cptn.collect_golds(@map.golds)
  348. @cptn.collect_shops(@map.shops)
  349. @cptn.collect_helmets(@map.helmets)
  350. @cptn.collect_firecrystals(@map.firecrystals)
  351. @cptn.collect_firebooks(@map.firebooks)
  352. @cptn.collect_icecrystals(@map.icecrystals)
  353. @cptn.collect_icebooks(@map.icebooks)
  354. @cptn.collect_lightningcrystals(@map.lightningcrystals)
  355. @cptn.collect_lightningbooks(@map.lightningbooks)
  356. @cptn.collect_earthcrystals(@map.earthcrystals)
  357. @cptn.collect_earthbooks(@map.earthbooks)
  358. @cptn.collect_evilbooks(@map.evilbooks)
  359. @cptn.collect_swordsandgreyshields(@map.swordsandgreyshields)
  360. @cptn.collect_groundareagates(@map.groundareagates)
  361. @cptn.collect_bluepotions(@map.bluepotions)
  362. @cptn.collect_redpotions(@map.redpotions)
  363. @cptn.collect_goldpotions(@map.goldpotions)
  364. @cptn.collect_greenpotions(@map.greenpotions)
  365. @cptn.hit_checkpoint(@map.checkpoints)
  366. @cptn.hit_fires(@map.fires)
  367. @cptn.hit_snakes(@map.snakes)
  368. @cptn.collect_greyshields(@map.greyshields)
  369. @cptn.collect_powerupswords(@map.powerupswords)
  370.  
  371.  
  372. # Scrolling follows player
  373. @screen_x = [[$x - @gamexres/2, 0].max, @map.width * 50 - @gamexres].min
  374. @screen_y = [[$y - @gameyres/2, 0].max, @map.height * 50 - @gameyres].min
  375. end
  376.  
  377. end
  378. def draw
  379.  
  380. if $gamemode == 1 then
  381.  
  382. @titlescreenimage.draw(0, 0, 0)
  383. #@titlefont1.draw("Press Spacebar or Start Button to Make Selection" , 200, 580,1, 1.0, 1.0, 0xffffffff)
  384. @fontsmall.draw("V0.4" , 1230, @gameyres -20,1, 1.0, 1.0, 0xffffffff)
  385. if $titlescreeniconpos == 1 then @menuicon.draw(450, 190, 0) end
  386. if $titlescreeniconpos == 2 then @menuicon.draw(450, 245, 0) end
  387. if $titlescreeniconpos == 3 then @menuicon.draw(450, 305, 0) end
  388. if $titlescreeniconpos == 4 then @menuicon.draw(450, 365, 0) end
  389. if $titlescreeniconpos == 5 then @menuicon.draw(450, 425, 0) end
  390. if $titlescreeniconpos == 6 then @menuicon.draw(450, 480, 0) end
  391. end
  392.  
  393. if $gamemode == 6 then
  394.  
  395.  
  396. @creditspage.draw(0, 0, 0)
  397.  
  398.  
  399.  
  400. end
  401.  
  402.  
  403. if $gamemode == 5 then
  404.  
  405. if $htpgpagenum == 1 then @howtoplayguidepage1.draw(0, 0, 0) end
  406. if $htpgpagenum == 2 then @howtoplayguidepage2.draw(0, 0, 0) end
  407. if $htpgpagenum == 3 then @howtoplayguidepage3.draw(0, 0, 0) end
  408. if $htpgpagenum == 4 then @howtoplayguidepage4.draw(0, 0, 0) end
  409.  
  410.  
  411.  
  412. end
  413.  
  414. if $gamemode == 0 then
  415. $titlescreenmusicogg.play(looping = true)
  416. $gamemode = 1
  417. $pausescreeniconpos = 1
  418. end
  419.  
  420.  
  421. if $gamemode == 10 then
  422.  
  423. $titlescreenmusicogg.stop
  424. @cptn.setnewgamevars
  425.  
  426. if $loadedstuff == 0 then
  427. $normalareatileset = Image.load_tiles(self, "data/tiles/normalrealmtileset.png", 60, 60, true)
  428. $fireareatileset = Image.load_tiles(self, "data/tiles/firerealmtileset.png", 60, 60, true)
  429. $iceareatileset = Image.load_tiles(self, "data/tiles/icerealmtileset3.png", 60, 60, true)
  430. $lightningareatileset = Image.load_tiles(self, "data/tiles/lightningrealmtileset.png", 60, 60, true)
  431. $groundareatileset = Image.load_tiles(self, "data/tiles/groundrealmtileset.png", 60, 60, true)
  432. $desertareatileset = Image.load_tiles(self, "data/tiles/groundrealmtileset.png", 60, 60, true)
  433. $evilareatileset = Image.load_tiles(self, "data/tiles/evilrealmtileset.png", 60, 60, true)
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440. @currentareabkimage = Image.new(self, "data/backgrounds/blank.png", true)
  441. @area1bk = Image.new(self, "data/backgrounds/area1bk.png", true)
  442. @area2bk = Image.new(self, "data/backgrounds/area2bk.png", true)
  443. @area3bk = Image.new(self, "data/backgrounds/area3bk.png", true)
  444. @area4bk = Image.new(self, "data/backgrounds/area4bk.png", true)
  445. @area5bk = Image.new(self, "data/backgrounds/area5bk.png", true)
  446. @area6bk = Image.new(self, "data/backgrounds/area6bk.png", true)
  447. @area7bk = Image.new(self, "data/backgrounds/area7bk.png", true)
  448. @area8bk = Image.new(self, "data/backgrounds/area8bk.png", true)
  449. @area9bk = Image.new(self, "data/backgrounds/area9bk.png", true)
  450. @evilareabk = Image.new(self, "data/backgrounds/area9bk.png", true)
  451. @fireareabk = Image.new(self, "data/backgrounds/firedungeonbk.png", true)
  452. @groundareabk = Image.new(self, "data/backgrounds/grounddungeonbk.png", true)
  453. @iceareabk = Image.new(self, "data/backgrounds/icedungeonbk.png", true)
  454. @lightningareabk = Image.new(self, "data/backgrounds/lightningdungeonbk.png", true)
  455.  
  456. @sprlives = Image.new(self, "data/items/helmet.png", true)
  457. @sprlrp = Image.new(self, "data/items/largeredpotion.png", true)
  458. @sprlbp = Image.new(self, "data/items/largebluepotion.png", true)
  459. @sprlgp = Image.new(self, "data/items/largegoldpotion.png", true)
  460. @sprlgrp = Image.new(self, "data/items/largegreenpotion.png", true)
  461. @sprlgreyp = Image.new(self, "data/items/largegreypotion.png", true)
  462.  
  463. @sprbookfire = Image.new(self, "data/items/bookfire.png", true)
  464. @sprbookice = Image.new(self, "data/items/bookice.png", true)
  465. @sprbooklightning = Image.new(self, "data/items/booklightning.png", true)
  466. @sprbookground = Image.new(self, "data/items/bookground.png", true)
  467. @sprbookevil = Image.new(self, "data/items/bookevil.png", true)
  468. @sprbookgrey = Image.new(self, "data/items/bookgrey.png", true)
  469.  
  470. @sprweapon1 = Image.new(self, "data/items/dagger1-1.png", true)
  471. @sprweapon2 = Image.new(self, "data/items/dagger2-1.png", true)
  472. @sprweapon3 = Image.new(self, "data/items/dagger3-1.png", true)
  473. @sprweapon4 = Image.new(self, "data/items/dagger4-1.png", true)
  474. @sprweapon5 = Image.new(self, "data/items/dagger5-1.png", true)
  475. @sprweapon6 = Image.new(self, "data/items/dagger6-1.png", true)
  476.  
  477. @sprweapon1grey = Image.new(self, "data/items/dagger1-3.png", true)
  478. @sprweapon2grey = Image.new(self, "data/items/dagger2-3.png", true)
  479. @sprweapon3grey = Image.new(self, "data/items/dagger3-3.png", true)
  480. @sprweapon4grey = Image.new(self, "data/items/dagger4-3.png", true)
  481. @sprweapon5grey = Image.new(self, "data/items/dagger5-3.png", true)
  482. @sprweapon6grey = Image.new(self, "data/items/dagger6-3.png", true)
  483.  
  484. @sprarmour1 = Image.new(self, "data/items/armourbronze.png", true)
  485. @sprarmour2 = Image.new(self, "data/items/armourred.png", true)
  486. @sprarmour3 = Image.new(self, "data/items/armourblue.png", true)
  487. @sprarmour4 = Image.new(self, "data/items/armourgreen.png", true)
  488. @sprarmour5 = Image.new(self, "data/items/armourpurple.png", true)
  489. @sprarmour6 = Image.new(self, "data/items/armourgold.png", true)
  490. @sprarmour7 = Image.new(self, "data/items/armourgrey.png", true)
  491.  
  492. @sprboots1 = Image.new(self, "data/items/bootsnormal.png", true)
  493. @sprboots2 = Image.new(self, "data/items/bootsmisc.png", true)
  494. @sprboots3 = Image.new(self, "data/items/bootsheavy.png", true)
  495. @sprboots4 = Image.new(self, "data/items/bootswaterice.png", true)
  496. @sprboots5 = Image.new(self, "data/items/bootspoison.png", true)
  497. @sprboots6 = Image.new(self, "data/items/bootsfeather.png", true)
  498. @sprboots7 = Image.new(self, "data/items/bootsgrey.png", true)
  499.  
  500. @sprstatus1 = Image.new(self, "data/items/status1.png", true)
  501. @sprstatus2 = Image.new(self, "data/items/status2.png", true)
  502. @sprstatus3 = Image.new(self, "data/items/status3.png", true)
  503. @sprstatus4 = Image.new(self, "data/items/status4.png", true)
  504. @sprstatus5 = Image.new(self, "data/items/status5.png", true)
  505. @sprstatus6 = Image.new(self, "data/items/status6.png", true)
  506.  
  507.  
  508. @selectedgroup1box = Image.new(self, "data/items/selectedgroup1box.png", true)
  509. @selectedgroup2box = Image.new(self, "data/items/selectedgroup2box.png", true)
  510. @selectedgroup3box = Image.new(self, "data/items/selectedgroup3box.png", true)
  511. @selectedgroup4box = Image.new(self, "data/items/selectedgroup4box.png", true)
  512. @selectedgroup5box = Image.new(self, "data/items/selectedgroup5box.png", true)
  513.  
  514. $loadedstuff = 1
  515. end
  516.  
  517. @map = Map.new(self, "data/maps/template.map")
  518. $area1map = Map.new(self, "data/maps/area1.map")
  519. $area2map = Map.new(self, "data/maps/area2.map")
  520. $area3map = Map.new(self, "data/maps/area3.map")
  521. $area4map = Map.new(self, "data/maps/area4.map")
  522. $area5map = Map.new(self, "data/maps/area5.map")
  523. $area6map = Map.new(self, "data/maps/area6.map")
  524. $area7map = Map.new(self, "data/maps/area7.map")
  525. $area8map = Map.new(self, "data/maps/area8.map")
  526. $area9map = Map.new(self, "data/maps/area9.map")
  527. $fireareamap = Map.new(self, "data/maps/firedungeon.map")
  528. $iceareamap = Map.new(self, "data/maps/icedungeon.map")
  529. $lightningareamap = Map.new(self, "data/maps/lightningdungeon.map")
  530. $groundareamap = Map.new(self, "data/maps/grounddungeon.map")
  531. $evilareamap = Map.new(self, "data/maps/evildungeon.map")
  532.  
  533.  
  534. $normalareamusicogg.play(looping = true)
  535. $gamemode = 2
  536.  
  537.  
  538. end
  539.  
  540. if $gamemode == 11 then
  541.  
  542. @introimage.draw(0, 0, 0)
  543.  
  544. $gamemode = 10
  545. end
  546.  
  547.  
  548. if $gamemode == 2 then
  549.  
  550.  
  551.  
  552. if $currentarea == 1 or $currentarea == 2 or $currentarea == 4 or $currentarea == 5 or $currentarea == 7 or $currentarea == 8 and $x>12470 then
  553. #$teleportgatesound.play
  554. $x = 25
  555. $dir = :right
  556. $currentarea += 1
  557.  
  558. changemusic
  559.  
  560. end
  561.  
  562.  
  563. if $currentarea == 2 or $currentarea == 3 or $currentarea == 5 or $currentarea == 6 or $currentarea == 8 or $currentarea == 9 and $x>10 and $x<25 then
  564. #$teleportgatesound.play
  565. $x = 12450
  566. $dir = :left
  567. $currentarea -= 1
  568.  
  569. changemusic
  570. end
  571.  
  572.  
  573. if $currentarea == 1 or $currentarea == 2 or $currentarea == 3 or $currentarea == 4 or $currentarea == 5 or $currentarea == 6 and $y>9975 then
  574. #$teleportgatesound.play
  575. $y = 56
  576. $currentarea += 3
  577. changemusic
  578. end
  579.  
  580.  
  581. if $currentarea == 4 or $currentarea == 5 or $currentarea == 6 or $currentarea == 7 or $currentarea == 8 or $currentarea == 9 and $y>45 and $y<55 then
  582. #$teleportgatesound.play
  583. $y = 9975
  584. $currentarea -= 3
  585. changemusic
  586. end
  587.  
  588.  
  589. if $currentarea == 15 and $x>12475 and $x<12495 and $y<9950 and $y>9800 then
  590. #$teleportgatesound.play
  591. $x = 18760
  592. $y = 18699
  593. $dir = :right
  594. $currentarea = 1
  595. $normalareamusicogg.play(looping = true)
  596. end
  597.  
  598.  
  599. if $currentarea == 1 then @currentareabkimage = @area1bk and @map = $area1map end
  600. if $currentarea == 2 then @currentareabkimage = @area2bk and @map = $area2map end
  601. if $currentarea == 3 then @currentareabkimage = @area3bk and @map = $area3map end
  602. if $currentarea == 4 then @currentareabkimage = @area4bk and @map = $area4map end
  603. if $currentarea == 5 then @currentareabkimage = @area5bk and @map = $area5map end
  604. if $currentarea == 6 then @currentareabkimage = @area6bk and @map = $area6map end
  605. if $currentarea == 7 then @currentareabkimage = @area7bk and @map = $area7map end
  606. if $currentarea == 8 then @currentareabkimage = @area8bk and @map = $area8map end
  607. if $currentarea == 9 then @currentareabkimage = @area9bk and @map = $area9map end
  608. if $currentarea == 10 then @currentareabkimage = @fireareabk and @map = $fireareamap end
  609. if $currentarea == 11 then @currentareabkimage = @iceareabk and @map = $iceareamap end
  610. if $currentarea == 12 then @currentareabkimage = @lightningareabk and @map = $lightningareamap end
  611. if $currentarea == 13 then @currentareabkimage = @groundareabk and @map = $groundareamap end
  612. if $currentarea == 15 then @currentareabkimage = @evilareabk and @map = $evilareamap end
  613.  
  614.  
  615.  
  616.  
  617.  
  618. @currentareabkimage.draw(-@screen_x/8, -@screen_y/8, 0)
  619.  
  620. @map.draw @screen_x, @screen_y , @gamexres , @gameyres
  621. @cptn.draw @screen_x, @screen_y
  622. @sprlives.draw(1055, -5, 0)
  623. @font.draw("#{$arthurlives} Lvl: #{@cptn.arthurlevel} " , 1090, 10,1, 1.0, 1.0, 0xffffffff)
  624. @font.draw("Exp: #{@cptn.arthurexp}" , 1070, 30,1, 1.0, 1.0, 0xffffffff)
  625. @font.draw("Gold: #{$gold}" , 1070, 50,1, 1.0, 1.0, 0xffffffff)
  626.  
  627. @objects.each { |o| o.draw }
  628.  
  629. #@font.draw("HP: #{@cptn.arthurhp}/#{@cptn.arthurmaxhp} MP: #{@cptn.arthurmp}/#{@cptn.arthurmaxmp} Exp: #{@cptn.arthurexp} WAB: #{@cptn.arthurweaponattboost}% PDB: #{@cptn.arthurpsysicaldefenceboost}% Level: #{@cptn.arthurlevel} Rubys: #{@cptn.gold} Lives: #{@cptn.arthurlives}", 10, 196,1, 1.0, 1.0, 0xffffffff)
  630. @fontsmall.draw("#{@cptn.arthurfiremagicboost}%", 202, 35,1, 1.0, 1.0, 0xffffffff)
  631. @fontsmall.draw("#{@cptn.arthuricemagicboost}%", 237, 35,1, 1.0, 1.0, 0xffffffff)
  632. @fontsmall.draw("#{@cptn.arthurlightningmagicboost}%", 272, 35,1, 1.0, 1.0, 0xffffffff)
  633. @fontsmall.draw("#{@cptn.arthurearthmagicboost}%", 307, 35,1, 1.0, 1.0, 0xffffffff)
  634. @fontsmall.draw("#{@cptn.arthurevilmagicboost}%", 202, 80,1, 1.0, 1.0, 0xffffffff)
  635. @font.draw("AD:#{@cptn.arthurdamage} SX:#{@screen_x} SY:#{@screen_y}" , 700, 115,1, 1.0, 1.0, 0xffffffff)
  636. @font.draw("X:#{$x} Y:#{$y}" , 700, 100,1, 1.0, 1.0, 0xffffffff)
  637. @font.draw("scrX:#{$scrx} scrY:#{$scry}" , 700, 150,1, 1.0, 1.0, 0xffffffff)
  638.  
  639.  
  640. @fontsmall.draw("Current area:#{$currentarea} selectedgroup:#{$selectedgroup} " , 1000, 100,1, 1.0, 1.0, 0xffffffff)
  641. #@fontsmall.draw("rannum:#{@rannum} " , 1000, 130,1, 1.0, 1.0, 0xffffffff)
  642.  
  643. @font.draw("#{$numredpotions} ", 45, 11,1, 1.0, 1.0, 0xffffffff)
  644. @font.draw("#{$numbluepotions} ", 89, 11,1, 1.0, 1.0, 0xffffffff)
  645. @font.draw("#{$numgoldpotions} ", 134, 11,1, 1.0, 1.0, 0xffffffff)
  646. @font.draw("#{$numgreenpotions} ", 178, 11,1, 1.0, 1.0, 0xffffffff)
  647.  
  648. if $selectedgroup ==1 then @selectedgroup1box.draw(10, 0, 0) end
  649. if $selectedgroup ==2 then @selectedgroup2box.draw(200, 0, 0) end
  650. if $selectedgroup ==3 then @selectedgroup3box.draw(342, 0, 0) end
  651. if $selectedgroup ==4 then @selectedgroup4box.draw(472, 0, 0) end
  652. if $selectedgroup ==5 then @selectedgroup5box.draw(596, 0, 0) end
  653.  
  654. if $numredpotions>0 then @sprlrp.draw(8, -15, 0) else @sprlgreyp.draw(8, -15, 0) end
  655. if $numbluepotions>0 then @sprlbp.draw(52, -15, 0) else @sprlgreyp.draw(52, -15, 0) end
  656. if $numgoldpotions>0 then @sprlgp.draw(96, -15, 0) else @sprlgreyp.draw(96, -15, 0) end
  657. if $numgreenpotions>0 then @sprlgrp.draw(140, -15, 0) else @sprlgreyp.draw(140, -15, 0) end
  658.  
  659. if @cptn.arthurfiremagicboost>0 then @sprbookfire.draw(195, -5, 0) else @sprbookgrey.draw(195, -5, 0) end
  660. if @cptn.arthuricemagicboost>0 then @sprbookice.draw(230, -5, 0) else @sprbookgrey.draw(230, -5, 0) end
  661. if @cptn.arthurlightningmagicboost>0 then @sprbooklightning.draw(265, -5, 0) else @sprbookgrey.draw(265, -5, 0) end
  662. if @cptn.arthurearthmagicboost>0 then @sprbookground.draw(300, -5, 0) else @sprbookgrey.draw(300, -5, 0) end
  663. if @cptn.arthurevilmagicboost>0 then @sprbookevil.draw(195, 40, 0) else @sprbookgrey.draw(195, 40, 0) end
  664.  
  665.  
  666. if @cptn.arthurweapon1>0 then @sprweapon1.draw(345, -5, 0) else @sprweapon1grey.draw(345, -5, 0) end
  667. if @cptn.arthurweapon2>0 then @sprweapon2.draw(380, -5, 0) else @sprweapon2grey.draw(380, -5, 0) end
  668. if @cptn.arthurweapon3>0 then @sprweapon3.draw(415, -5, 0) else @sprweapon3grey.draw(415, -5, 0) end
  669. if @cptn.arthurweapon4>0 then @sprweapon4.draw(345, 40, 0) else @sprweapon4grey.draw(345, 40, 0) end
  670. if @cptn.arthurweapon5>0 then @sprweapon5.draw(380, 40, 0) else @sprweapon5grey.draw(380, 40, 0) end
  671. if @cptn.arthurweapon6>0 then @sprweapon6.draw(415, 40, 0) else @sprweapon6grey.draw(415, 40, 0) end
  672.  
  673. if @cptn.arthurarmour1>0 then @sprarmour1.draw(485, 5, 0) else @sprarmour7.draw(485, 5, 0) end
  674. if @cptn.arthurarmour2>0 then @sprarmour2.draw(520, 5, 0) else @sprarmour7.draw(520, 5, 0) end
  675. if @cptn.arthurarmour3>0 then @sprarmour3.draw(555, 5, 0) else @sprarmour7.draw(555, 5, 0) end
  676. if @cptn.arthurarmour4>0 then @sprarmour4.draw(485, 50, 0) else @sprarmour7.draw(485, 50, 0) end
  677. if @cptn.arthurarmour5>0 then @sprarmour5.draw(520, 50, 0) else @sprarmour7.draw(520, 50, 0) end
  678. if @cptn.arthurarmour6>0 then @sprarmour6.draw(555, 50, 0) else @sprarmour7.draw(555, 50, 0) end
  679.  
  680.  
  681. if @cptn.arthurboots1>0 then @sprboots1.draw(600, 5, 0) else @sprboots7.draw(600, 5, 0) end
  682. if @cptn.arthurboots2>0 then @sprboots2.draw(635, 5, 0) else @sprboots7.draw(635, 5, 0) end
  683. if @cptn.arthurboots3>0 then @sprboots3.draw(670, 5, 0) else @sprboots7.draw(670, 5, 0) end
  684. if @cptn.arthurboots4>0 then @sprboots4.draw(600, 50, 0) else @sprboots7.draw(600, 50, 0) end
  685. if @cptn.arthurboots5>0 then @sprboots5.draw(635, 50, 0) else @sprboots7.draw(635, 50, 0) end
  686. if @cptn.arthurboots6>0 then @sprboots6.draw(670, 50, 0) else @sprboots7.draw(670, 50, 0) end
  687.  
  688. if @cptn.arthurstatus1>0 then @sprstatus1.draw(30, 65, 0) end
  689. if @cptn.arthurstatus2>0 then @sprstatus2.draw(55, 65, 0) end
  690. if @cptn.arthurstatus3>0 then @sprstatus3.draw(80, 65, 0) end
  691. if @cptn.arthurstatus4>0 then @sprstatus4.draw(105, 65, 0) end
  692. if @cptn.arthurstatus5>0 then @sprstatus5.draw(130, 65, 0) end
  693. if @cptn.arthurstatus6>0 then @sprstatus6.draw(155, 65, 0) end
  694.  
  695.  
  696. #draw hpenergybar
  697.  
  698. draw_line(10,100,@hpbarcolor2,@cptn.arthurmaxhp+10,100,@hpbarcolor2,z=0)
  699. draw_line(10,101,@hpbarcolor2,@cptn.arthurmaxhp+10,101,@hpbarcolor2,z=0)
  700. draw_line(10,102,@hpbarcolor2,@cptn.arthurmaxhp+10,102,@hpbarcolor2,z=0)
  701. draw_line(10,103,@hpbarcolor2,@cptn.arthurmaxhp+10,103,@hpbarcolor2,z=0)
  702. draw_line(10,104,@hpbarcolor2,@cptn.arthurmaxhp+10,104,@hpbarcolor2,z=0)
  703. draw_line(10,105,@hpbarcolor2,@cptn.arthurmaxhp+10,105,@hpbarcolor2,z=0)
  704.  
  705.  
  706. draw_line(10,100,@hpbarcolor,@cptn.arthurhp+10,100,@hpbarcolor,z=0)
  707. draw_line(10,101,@hpbarcolor,@cptn.arthurhp+10,101,@hpbarcolor,z=0)
  708. draw_line(10,102,@hpbarcolor,@cptn.arthurhp+10,102,@hpbarcolor,z=0)
  709. draw_line(10,103,@hpbarcolor,@cptn.arthurhp+10,103,@hpbarcolor,z=0)
  710. draw_line(10,104,@hpbarcolor,@cptn.arthurhp+10,104,@hpbarcolor,z=0)
  711. draw_line(10,105,@hpbarcolor,@cptn.arthurhp+10,105,@hpbarcolor,z=0)
  712.  
  713. #draw mpenergybar
  714. draw_line(10,110,@mpbarcolor2,@cptn.arthurmaxmp+10,110,@mpbarcolor2,z=0)
  715. draw_line(10,111,@mpbarcolor2,@cptn.arthurmaxmp+10,111,@mpbarcolor2,z=0)
  716. draw_line(10,112,@mpbarcolor2,@cptn.arthurmaxmp+10,112,@mpbarcolor2,z=0)
  717. draw_line(10,113,@mpbarcolor2,@cptn.arthurmaxmp+10,113,@mpbarcolor2,z=0)
  718. draw_line(10,114,@mpbarcolor2,@cptn.arthurmaxmp+10,114,@mpbarcolor2,z=0)
  719. draw_line(10,115,@mpbarcolor2,@cptn.arthurmaxmp+10,115,@mpbarcolor2,z=0)
  720.  
  721. draw_line(10,110,@mpbarcolor,@cptn.arthurmp+10,110,@mpbarcolor,z=0)
  722. draw_line(10,111,@mpbarcolor,@cptn.arthurmp+10,111,@mpbarcolor,z=0)
  723. draw_line(10,112,@mpbarcolor,@cptn.arthurmp+10,112,@mpbarcolor,z=0)
  724. draw_line(10,113,@mpbarcolor,@cptn.arthurmp+10,113,@mpbarcolor,z=0)
  725. draw_line(10,114,@mpbarcolor,@cptn.arthurmp+10,114,@mpbarcolor,z=0)
  726. draw_line(10,115,@mpbarcolor,@cptn.arthurmp+10,115,@mpbarcolor,z=0)
  727.  
  728. @fps_check.register_tick
  729. @font.draw("FPS #{@fps_check.fps}", 1200, 100, 1, 1.0, 1.0, 0xffffff00)
  730. end
  731.  
  732. if $gamemode == 13 then
  733.  
  734. @shopscreenimage.draw(0, 0, 0)
  735. @font.draw("#{$gold}" , 1110, 27,1, 1.0, 1.0, 0xff000000)
  736. if $shopscreeniconpos == 1 then @menuicon.draw(400, 230, 0) end
  737. if $shopscreeniconpos == 2 then @menuicon.draw(400, 275, 0) end
  738. if $shopscreeniconpos == 3 then @menuicon.draw(400, 325, 0) end
  739. if $shopscreeniconpos == 4 then @menuicon.draw(400, 365, 0) end
  740. if $shopscreeniconpos == 5 then @menuicon.draw(400, 405, 0) end
  741.  
  742. end
  743.  
  744.  
  745. if $gamemode == 3 then
  746.  
  747. @pausescreenimage.draw(0, 0, 0)
  748.  
  749. if $pausescreeniconpos == 1 then @menuicon.draw(400, 220, 0) end
  750. if $pausescreeniconpos == 2 then @menuicon.draw(400, 310, 0) end
  751. if $pausescreeniconpos == 3 then @menuicon.draw(400, 395, 0) end
  752. if $pausescreeniconpos == 4 then @menuicon.draw(400, 480, 0) end
  753.  
  754. end
  755.  
  756. if $gamemode == 4 then
  757.  
  758. $gamemode = 2
  759. changemusic
  760. end
  761.  
  762. end
  763.  
  764.  
  765. def button_down(id)
  766.  
  767. if $gamemode == 6 then
  768.  
  769. if id == Button::KbSpace or id == Button::GpButton9 then @menupressbuttonsound.play and $gamemode = 0 end
  770.  
  771.  
  772. end
  773.  
  774.  
  775. if $gamemode == 5 then
  776.  
  777. if id == Button::KbSpace or id == Button::GpButton9 then @menupressbuttonsound.play and $gamemode = $lastgamemode end
  778.  
  779. if id == Button::KbLeft or id == Button::GpLeft then $htpgpagenum -= 1 and @menumovesound.play end
  780. if id == Button::KbRight or id == Button::GpRight then $htpgpagenum += 1 and @menumovesound.play end
  781.  
  782. if $htpgpagenum == 0 then $htpgpagenum = 4 end
  783. if $htpgpagenum == 5 then $htpgpagenum = 1 end
  784. end
  785.  
  786. if $gamemode == 13 then
  787.  
  788. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 1 then if $gold<50 then @errorsound.play end end
  789. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 1 then if $gold>49 then $numredpotions += 1 and $gold -= 50 and @buyitemsound.play end end
  790. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 2 then if $gold<50 then @errorsound.play end end
  791. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 2 then if $gold>49 then $numbluepotions += 1 and $gold -= 50 and @buyitemsound.play end end
  792. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 3 then if $gold<50 then @errorsound.play end end
  793. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 3 then if $gold>149 then $numgoldpotions += 1 and $gold -= 150 and @buyitemsound.play end end
  794. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 4 then if $gold<80 then @errorsound.play end end
  795. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 4 then if $gold>79 then $numgreenpotions += 1 and $gold -= 80 and @buyitemsound.play end end
  796. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 5 then if $gold<1000 then @errorsound.play end end
  797. if id == Button::KbJ or id == Button::GpButton2 and $shopscreeniconpos == 5 then if $gold>999 then $arthurlives += 1 and $gold -= 1000 and @buyitemsound.play end end
  798. if id == Button::KbK or id == Button::GpButton1 and @menupressbuttonsound.play then $gamemode = 4 end
  799.  
  800. if id == Button::KbUp or id == Button::GpUp then $shopscreeniconpos -= 1 and @menumovesound.play end
  801. if id == Button::KbDown or id == Button::GpDown then $shopscreeniconpos += 1 and @menumovesound.play end
  802.  
  803. if $shopscreeniconpos == 0 then $shopscreeniconpos = 5 end
  804. if $shopscreeniconpos == 6 then $shopscreeniconpos = 1 end
  805. end
  806.  
  807.  
  808. if $gamemode == 3 then
  809.  
  810. if id == Button::KbSpace or id == Button::GpButton9 and @unpausebuttonsound.play and $pausescreeniconpos == 1 then $gamemode = 4 end
  811. if id == Button::KbSpace or id == Button::GpButton9 and @menupressbuttonsound.play and $pausescreeniconpos == 2 then $gamemode = 5 and $lastgamemode = 12 end
  812. if id == Button::KbSpace or id == Button::GpButton9 and @menupressbuttonsound.play and $pausescreeniconpos == 4 then $gamemode = 0 end
  813.  
  814. if id == Button::KbUp or id == Button::GpUp then $pausescreeniconpos -= 1 and @menumovesound.play end
  815. if id == Button::KbDown or id == Button::GpDown then $pausescreeniconpos += 1 and @menumovesound.play end
  816.  
  817. if $pausescreeniconpos == 0 then $pausescreeniconpos = 4 end
  818. if $pausescreeniconpos == 5 then $pausescreeniconpos = 1 end
  819. end
  820.  
  821.  
  822.  
  823.  
  824. if $gamemode == 1 then
  825. if id == Button::KbSpace or id == Button::GpButton9 and $titlescreeniconpos == 1 then @menupressbuttonsound.play and $currentarea = 1 and $gamemode = 11 end
  826. if id == Button::KbSpace or id == Button::GpButton9 and $titlescreeniconpos == 3 then @menupressbuttonsound.play and $gamemode = 5 and $lastgamemode = 0 end
  827. if id == Button::KbSpace or id == Button::GpButton9 and $titlescreeniconpos == 5 then @menupressbuttonsound.play and $gamemode = 6 end
  828. if id == Button::KbEscape or id == Button::KbSpace or id == Button::GpButton9 and $titlescreeniconpos == 6 then close end
  829. if id == Button::KbEscape then close end
  830. if id == Button::KbUp or id == Button::GpUp then $titlescreeniconpos -= 1 and @menumovesound.play end
  831. if id == Button::KbDown or id == Button::GpDown then $titlescreeniconpos += 1 and @menumovesound.play end
  832.  
  833.  
  834. if $titlescreeniconpos == 0 then $titlescreeniconpos = 6 end
  835. if $titlescreeniconpos == 7 then $titlescreeniconpos = 1 end
  836. end
  837.  
  838. if $gamemode == 10 then
  839.  
  840. end
  841.  
  842.  
  843.  
  844. if $gamemode == 2 then
  845.  
  846.  
  847. if id == Gosu::KbD or id == Button::GpButton1 then
  848. # Shoot! This is handled in button_down because holding space shouldn't
  849. # auto-fire - the shots would come from different players.
  850. if $dir == :left then @players[0].shootleft end
  851. if $dir == :right then @players[0].shootright end
  852. #@current_player = 1 - @current_player
  853. #@waiting = true
  854. end
  855.  
  856.  
  857. if id== Button::KbUp or id == Button::GpButton2 or id == Button::KbC then @cptn.try_to_jump end
  858. if id == Button::KbZ or id == Button::GpButton3 or id == Button::KbReturn or id == Button::MsMiddle then @cptn.useitem end
  859. if id == Button::KbQ or id == Button::KbNumpad9 or id == Button::GpButton5 or id == Button::MsWheelDown and $selectedgroup == 1 then @cptn.changeitemforward end
  860. if id == Button::KbA or id == Button::KbNumpad3 or id == Button::GpButton4 or id == Button::MsWheelUp and $selectedgroup == 1 then @cptn.changeitembackward end
  861.  
  862. if id == Button::KbW or id == Button::KbNumpad7 or id == Button::GpButton7 then $selectedgroup += 1 end
  863. if id == Button::KbS or id == Button::KbNumpad1 or id == Button::GpButton6 then $selectedgroup -= 1 end
  864.  
  865. if $selectedgroup == 0 then $selectedgroup = 5 end
  866. if $selectedgroup == 6 then $selectedgroup = 1 end
  867.  
  868. if id == Button::KbSpace or id == Button::GpButton9 then
  869. pausemusic
  870. @pausebuttonsound.play
  871. $gamemode = 3
  872. end
  873.  
  874. if id == Button::KbUp or id == Button::GpUp and $touchingshop == 1 then
  875. pausemusic
  876. @pausebuttonsound.play
  877. $gamemode = 13
  878. end
  879.  
  880. if id == Button::KbEscape then $gamemode = 1 and $titlescreenmusicogg.play(looping = true) end
  881. end
  882.  
  883. if $gamemode == 12 then
  884. $gamemode = 3
  885. end
  886.  
  887.  
  888. end
  889.  
  890.  
  891.  
  892. end
  893.  
  894.  
  895. Game.new.show
Add Comment
Please, Sign In to add comment