Skip to content

Commit

Permalink
Added sticky ball power.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceronman committed Apr 15, 2012
1 parent 30650b9 commit 0d396a5
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 25 deletions.
78 changes: 68 additions & 10 deletions arkatinto.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added graphics/sticky_paddle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/ball.coffee
Expand Up @@ -59,6 +59,10 @@ class Ball extends Sprite
@y = paddle.top() - @height()

if key("space")
if paddle.sticky
# FIXME
@map.activeAction.stop()
@map.activeAction = null
@state = "playing"

updatePlaying: (dt) ->
Expand All @@ -80,7 +84,11 @@ class Ball extends Sprite
@speedY *= -1

if collision(this, paddle) == SIDE.top
@bouncePaddle(paddle)
if paddle.sticky
@init()
@state = "ready"
else
@bouncePaddle(paddle)

if @y > @limitBottom
@init()
Expand Down
10 changes: 8 additions & 2 deletions src/board.coffee
@@ -1,4 +1,5 @@
# Imports
key = tinto.input.key
resource = tinto.resource
Sprite = tinto.sprite.Sprite
Label = tinto.text.Label
Expand Down Expand Up @@ -54,7 +55,7 @@ class LevelMap
@ball = new Ball(this)
@bonus = null
@music = resource.sound("sounds/ride-the-storm.ogg")
@music.play()
# @music.play()

@stateLabel = new Label
font: "20pt Arial"
Expand Down Expand Up @@ -155,6 +156,11 @@ class LevelMap

@paddle.update dt
@bonus?.update dt

if (@ball.state == "playing" and key("space") and
@activeAction? and @activeAction.powerAction)
@activeAction.action()

@checkState()

draw: ->
Expand Down Expand Up @@ -195,7 +201,7 @@ class Board

@bonusLabel = new Label
font: "12pt Arial"
x: 200
x: 180
y: CONFIG.mapHeight + 3 * CONFIG.boardHeight / 4
text: ""

Expand Down
48 changes: 36 additions & 12 deletions src/bonus.coffee
Expand Up @@ -11,10 +11,11 @@ class BonusAction
execute: (map) ->
@map = map
@start()
setTimeout((=>
@end()
@map.activeAction = null
), @duration * 1000)
if @duration?
setTimeout((=>
@end()
@map.activeAction = null
), @duration * 1000)

remove: ->
@end()
Expand Down Expand Up @@ -166,18 +167,41 @@ class MirrorControlBonusAction extends BonusAction
@map.paddle.mirror = false


class StickyPaddleBonusAction extends BonusAction

@IMAGE = resource.image("graphics/sticky_paddle.png")
powerAction: true
duration: null

color: 'purple'
text: 'Atrapar: <espacio>'

start: ->
@oldImage = @map.paddle.image
end: ->

action: ->
@map.paddle.image = StickyPaddleBonusAction.IMAGE
@map.paddle.sticky = true

stop: ->
@map.paddle.image = @oldImage
@map.paddle.sticky = false


class Bonus extends Sprite

@IMAGE: resource.image("graphics/bonus.png")
@ACTIONS: [
ExtraLifeBonusAction,
LargePadBonusAction,
ShortPadBonusAction,
ExplosionBonusAction,
FastBallBonusAction,
SlowBallBonusAction,
FireBallBonusAction,
MirrorControlBonusAction,
# ExtraLifeBonusAction,
# LargePadBonusAction,
# ShortPadBonusAction,
# ExplosionBonusAction,
# FastBallBonusAction,
# SlowBallBonusAction,
# FireBallBonusAction,
# MirrorControlBonusAction,
StickyPaddleBonusAction
]

constructor: (@x, @y, @map) ->
Expand Down
1 change: 1 addition & 0 deletions src/paddle.coffee
Expand Up @@ -12,6 +12,7 @@ class Paddle extends Sprite

@speed = 300
@mirror = false
@sticky = false

init: ->
@x = CONFIG.mapWidth / 2 - @width() / 2
Expand Down

0 comments on commit 0d396a5

Please sign in to comment.