How do I make different coins different points?
I can't figure out how to make different coins wreath different points to the score
I can't figure out how to make different coins wreath different points to the score
Coin = class
constructor = function( str, val, pos_x, pos_y )
this.nane = str
this.value = val
this.x = pos_x
this.y = pos_y
end
end
Player = class
constructor = function()
this.coinA = 100
this.coinB = 200
end
setCointA = function( value )
this.coinA += value
end
setCoinB = function( value )
this.coinB += value
end
setCoin = function( coin )
if coin.name == "A" then
this.setCoinA( coin.value )
else
this.setCoinB( coin.value )
end
end
collide = function( coin )
//
end
end
init = function()
player = new Player()
coins = []
coins.push( new Coin("A", 123 ))
end
update = function()
coins.forEach( function( coin )
if player.collide( coin ) then player.setCoin( coin ) end
end )
end
Thanks :)