Hi, guys. Sorry for noob questions from me, but whats wrong in this piece of code?
Fishes = class()
function Fishes:init()
-- you can accept and set parameters here
self.fish = physics.body(CIRCLE,20)
self.fish.x = 100
self.fish.y = 0
end
function Fishes:draw()
ellipse(self.fish.x,self.fish.y,40) -- this string makes codea unhappy
end
function Fishes:touched(touch)
-- Codea does not automatically call this method
end
I expect codea dont like this values : “self.fish.x and self.fish.x”
--# Main
-- Kraken
-- Use this function to perform your initial setup
displayMode(FULLSCREEN)
function setup()
w = WIDTH/2
h = HEIGHT/2
xb = w
xs = h
xch = 270
xch = xch + 1
count = 1
floor = physics.body(EDGE,vec2(-WIDTH,0),vec2(WIDTH,0))
physics.pause()
grav = physics.gravity(Gravity)
ship = physics.body(CIRCLE,89)
ship.y = h+199
ship.restitution = 1
end
function touched(touch)
if touch.state == ENDED then
physics.resume()
end
end
function outofscreen()
if xb > w then
xb = 0
count = count + 1
elseif xb < w then
xb = 0
end
if xs > w then
xs = -20
end
end
function draw()
xch = xch + 1
-- if touch.state == ENDED then
-- ship.y = grav.y
-- end
pushStyle()
sprite("Documents:backgroundblur",w,h)
sprite("Documents:waveback",w-200,h+300)
sprite("Documents:waveback",w+250,h+300)
sprite("Documents:ship(vlad dont like this)",xch,ship.y,270,178)
sprite("Documents:wavefrontbig",w,h+280)
-- sprite("Documents:wavefront",w+440,h+290)
popStyle()
Fishes:draw()
end
--# Fishes
Fishes = class()
function Fishes:init()
-- you can accept and set parameters here
self.fish = physics.body(CIRCLE,20)
self.fish.x = 100
self.fish.y = 0
end
function Fishes:draw()
ellipse(self.fish.x,self.fish.y,40)
end
function Fishes:touched(touch)
-- Codea does not automatically call this method
end
Fishes is a class, not an instance of the class, you must create and draw one sample fish1 or more:
--# Main
-- Kraken
-- Use this function to perform your initial setup
displayMode(FULLSCREEN)
function setup()
w = WIDTH/2
h = HEIGHT/2
xb = w
xs = h
xch = 270
xch = xch + 1
count = 1
floor = physics.body(EDGE,vec2(-WIDTH,0),vec2(WIDTH,0))
physics.pause()
grav = physics.gravity(Gravity)
ship = physics.body(CIRCLE,89)
ship.y = h+199
ship.restitution = 1
fish1 = Fishes()
end
function touched(touch)
if touch.state == ENDED then
physics.resume()
end
end
function outofscreen()
if xb > w then
xb = 0
count = count + 1
elseif xb < w then
xb = 0
end
if xs > w then
xs = -20
end
end
function draw()
xch = xch + 1
-- if touch.state == ENDED then
-- ship.y = grav.y
-- end
pushStyle()
sprite("Documents:backgroundblur",w,h)
sprite("Documents:waveback",w-200,h+300)
sprite("Documents:waveback",w+250,h+300)
sprite("Documents:ship(vlad dont like this)",xch,ship.y,270,178)
sprite("Documents:wavefrontbig",w,h+280)
-- sprite("Documents:wavefront",w+440,h+290)
popStyle()
fish1:draw()
end
--# Fishes
Fishes = class()
function Fishes:init()
-- you can accept and set parameters here
self.fish = physics.body(CIRCLE,20)
self.fish.x = 100
self.fish.y = 0
end
function Fishes:draw()
ellipse(self.fish.x,self.fish.y,40)
end
function Fishes:touched(touch)
-- Codea does not automatically call this method
end