Skip to content

Commit

Permalink
Change player to witch and target to pumpkin. Change right & left but…
Browse files Browse the repository at this point in the history
…tons from angle to move.
  • Loading branch information
AndyFou committed Aug 10, 2016
1 parent 5e8e8e4 commit 5fe6556
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions init.rb
Expand Up @@ -4,17 +4,17 @@
class Haunted < Gosu::Window
WIN_WIDTH = 900
WIN_HEIGHT = 900
TARGET_WIDTH = 150
TARGET_HEIGHT = 680
TARGET_WIDTH = 750
TARGET_HEIGHT = 780

def initialize ## constructor
super(WIN_WIDTH,WIN_HEIGHT)
self.caption = "Haunted"

# Create images
@background_image = Gosu::Image.new("images/background.jpg", :tileable => true)
@witch = Gosu::Image.new("images/witch.png")
@target = Gosu::Image.new("images/star.png")
@star = Gosu::Image.new("images/star.png")
@target = Gosu::Image.new("images/pumpkin.png")
#@graveyard = Gosu::Image.new("images/graveyard.png")

# Create a player (from player.rb file)
Expand All @@ -34,7 +34,7 @@ def initialize ## constructor
def draw ## draw the items of the game
# Draw images
@background_image.draw(0,0,0)
@witch.draw(450, 200, 0)
@star.draw(150, 680, 0)
#@graveyard.draw(500, 760, 0)

@target.draw(TARGET_WIDTH,TARGET_HEIGHT,0)
Expand Down Expand Up @@ -67,7 +67,7 @@ def update ## animate the game (where objects are moved and user actions ar
end

def button_down(id)
if (id == Gosu::KbSpace)
if (id == Gosu::KbEnter)
@playing = true
@start_time = Gosu.milliseconds
### how to reset the player position??
Expand Down
12 changes: 7 additions & 5 deletions player.rb
Expand Up @@ -7,7 +7,7 @@ def initialize(window)
@x = 750
@y = 750
@angle = 0
@image = Gosu::Image.new('images/pumpkin.png')
@image = Gosu::Image.new('images/witch.png')
@velocity_x = 0
@velocity_y = 0
@radius = 20
Expand All @@ -19,20 +19,22 @@ def draw
end

def turn_right
@angle += ROTATION_SPEED
#@angle += ROTATION_SPEED # if left not move but change angle
@velocity_x += Gosu.offset_x(@angle+90, ACCELERATION)
end

def turn_left
@angle -= ROTATION_SPEED
#@angle -= ROTATION_SPEED # if right not move but change angle
@velocity_x -= Gosu.offset_x(@angle+90, ACCELERATION)
end

def accelerate
@velocity_x += Gosu.offset_x(@angle, ACCELERATION)
#@velocity_x += Gosu.offset_x(@angle, ACCELERATION) # if left & right not move but change angle
@velocity_y += Gosu.offset_y(@angle, ACCELERATION)
end

def goback
@velocity_x -= Gosu.offset_x(@angle, ACCELERATION)
#@velocity_x -= Gosu.offset_x(@angle, ACCELERATION) # if left & right not move but change angle
@velocity_y -= Gosu.offset_y(@angle, ACCELERATION)
end

Expand Down

0 comments on commit 5fe6556

Please sign in to comment.