TheoAllen

Iseng2 RGSSS3 (5) - Shooting

Apr 29th, 2013
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.62 KB | None | 0 0
  1. DataManager.init
  2. module Math
  3.   def self.radian(degree)
  4.     return (degree.to_f/180) * Math::PI
  5.   end
  6.  
  7.   def self.degree(radian)
  8.     return (radian.to_f/Math::PI) * 180
  9.   end
  10.  
  11.   class << self
  12.     alias theo_sin sin
  13.     alias theo_cos cos
  14.   end
  15.  
  16.   def self.sin(x)
  17.     return theo_sin(x) if x % radian(180) != 0
  18.     return 0.0
  19.   end
  20.  
  21.   def self.cos(x)
  22.     return theo_cos(x) if x % radian(0) != 0
  23.     return 0.0
  24.   end
  25. end
  26.  
  27. class Window_BulletTest < Window_Base
  28.   @@count = 0
  29.  
  30.   def initialize(x,y,width,height)
  31.     super(x,y,width,height)
  32.     @@count += 1
  33.   end
  34.  
  35.   def update_movement
  36.     self.y -= 3 unless disposed?
  37.   end
  38.  
  39.   alias bullet_dispose dispose
  40.   def dispose
  41.     bullet_dispose
  42.     @@count -= 1
  43.   end
  44.  
  45.   def self.count
  46.     @@count
  47.   end
  48.  
  49. end  
  50.  
  51. def updates
  52.   Graphics.update
  53.   Input.update
  54.   $bullet.each do |bullet|
  55.     next if bullet.nil?
  56.     bullet.update_movement
  57.     if bullet.y <= 0
  58.       $bullet.delete(bullet)
  59.       bullet.dispose
  60.     end
  61.   end
  62.   $window.x = $pusat.x + (50*Math.cos(Math.radian($test)))
  63.   $window.y = $pusat.y + (50*Math.sin(Math.radian($test)))
  64.   if Input.press?(:UP)
  65.     $pusat.y -= 3
  66.   elsif Input.press?(:DOWN)
  67.     $pusat.y += 3
  68.   elsif Input.press?(:LEFT)
  69.     $pusat.x -= 3
  70.   elsif Input.press?(:RIGHT)
  71.     $pusat.x += 3
  72.   elsif Input.trigger?(:C)
  73.     puts "shot!"
  74.     $bullet.push(Window_BulletTest.new($pusat.x,$pusat.y,24,24))
  75.   end
  76.   $test += 10
  77. end
  78.  
  79. $bullet = []
  80. $test = 0
  81. $pusat = Window_Base.new(100-12,200-12,24,24)
  82. $window = Window_Base.new(100-12,200-12,24,24)
  83. $window.viewport = Viewport.new
  84.  
  85. updates while true
Advertisement
Add Comment
Please, Sign In to add comment