Pleas i want from any one to make my buttons work when i press normal mode button go to normal_mode calss and when i press hard buttun go to hard_mode class pleas and pleas creat a eazy buttun and maket to go the easy class when youmgive me the code i well but the easy code game pleas i want a helpe this is the code
--This is the main menu
-- menu1
function setup()
sprite("Documents:sponge bob app icon",WIDTH/2,HEIGHT/2)
-- displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_RIGHT)
backingMode(RETAINED)
sprite("Documents:sponge bob app icon",WIDTH/2,HEIGHT/2)
end
function draw()
menu()
end
function menu()
background(245, 255, 0, 57)
sprite("Documents:basset",WIDTH-200,HEIGHT-600)
sprite("Documents:sponge bob",WIDTH/2,HEIGHT/11)
sprite("Documents:basset",WIDTH-800,HEIGHT-380)
sprite("Documents:sandy",WIDTH-350,HEIGHT-300)
sprite("Documents:mrs",WIDTH-200,HEIGHT-200)
sprite("Documents:the vilige",WIDTH-150,HEIGHT-400)
sprite("Documents:r",WIDTH-700,HEIGHT-500)
sprite("Documents:r",WIDTH-100,HEIGHT-100)
sprite("Documents:the vilig",WIDTH-900,HEIGHT-600)
sprite("Documents:mrs",WIDTH-800,HEIGHT-150)
w=WIDTH/2 -- set width value
eh=HEIGHT-300 -- set height of different options
nh=HEIGHT-400 -- eh easy, nh normal, hh hard
hh=HEIGHT-500
font("AmericanTypewriter-Bold") -- set font used
fontSize(54) -- set font size
fill(255, 0, 4, 255) -- set font co
menuTitle2=""
menuTitle1="main menu "
text(menuTitle1,w,HEIGHT-100) -- display titles
text(menuTitle2,w,HEIGHT-200)
fontSize(50)
font("SnellRoundhand") -- set
fill(9, 34, 251, 255) -- set easy values
t1="normal"
text(t1,w,eh)
w1,h1=textSize(t1) -- width and height of easy text
t2="hard" -- set normal values
text(t2,w,nh)
w2,h2=textSize(t2) -- width and height of normal text
t3="credits" -- set hard values
text(t3,w,hh)
w3,h3=textSize(t3) -- width and height of hard text
end
function touched(t)
if t.state==BEGAN then
if t.x>w-w1/2 and t.x<w+w1/2 and t.y>eh-h1/2 and t.y<eh+h1/2 then
print ("normal mode selected ")
end
if t.x>w-w2/2 and t.x<w+w2/2 and t.y>nh-h2/2 and t.y<nh+h2/2 then
print ("hard mode selected")
end
if t.x>w-w3/2 and t.x<w+w3/2 and t.y>hh-h3/2 and t.y<hh+h3/2 then
function touched(touch)
openURL( 'https://www.youtube.com/watch?v=j2ovNrJmjPo' )
end
end
end
end
This is the normal mode
--# Cloud
Cloud = class()
function Cloud:init()
-- you can accept and set parameters here
self.shapes = {}
self.position = vec2(0,0)
-- Generate random cloud
numCircles = math.random(4, 5)
spacing = 30
for i = 1,numCircles do
x = i * spacing - ((numCircles/2)*spacing)
y = (math.random() - 0.5) * 30
rad = math.random(spacing, 2*spacing)
table.insert(self.shapes, {x=x, y=y, r=rad})
end
self.width = numCircles * spacing + spacing
end
function Cloud:isColliding(pos)
startp = self.position.x - self.width/2
endp = self.position.x + self.width/2
if pos.x < endp and pos.x > startp and
pos.y < (self.position.y + 30) and
pos.y > (self.position.y + 10) then
return true
end
return false
end
function Cloud:draw()
pushStyle()
pushMatrix()
translate(self.position.x, self.position.y)
noStroke()
ellipseMode(RADIUS)
fill(255, 206, 0, 255)
for i,s in ipairs(self.shapes) do
ellipse(s.x, s.y - 5, s.r)
end
fill(229, 145, 8, 255)
for i,s in ipairs(self.shapes) do
ellipse(s.x, s.y + 5, s.r)
end
popMatrix()
popStyle()
end
--# CloudLevels
CloudLevels = class()
CULLPADDING = 300
function CloudLevels:init()
-- you can accept and set parameters here
self.clouds = {}
self.nextCloudHeight = 100
end
function CloudLevels:generateNextCloud()
cloud = Cloud()
cloud.position = vec2(math.random(-WIDTH/2,WIDTH/2),
self.nextCloudHeight)
table.insert(self.clouds, cloud)
self.nextCloudHeight = self.nextCloudHeight + math.random(150,300)
end
function CloudLevels:cullClouds(floor)
for i,v in ipairs(self.clouds) do
if v.position.y < floor then
table.remove(self.clouds,i)
end
end
end
function CloudLevels:isColliding(pos)
for i,v in ipairs(self.clouds) do
if v:isColliding(pos) then
return true
end
end
return false
end
function CloudLevels:update(cam)
curHeight = -cam.y + HEIGHT + CULLPADDING
if curHeight > self.nextCloudHeight then
self:generateNextCloud()
end
self:cullClouds(-cam.y - CULLPADDING)
end
function CloudLevels:draw()
-- Codea does not automatically call this method
for i,v in ipairs(self.clouds) do
v:draw()
end
end
function CloudLevels:touched(touch)
-- Codea does not automatically call this method
end
--# Super_sponge
Girl = class()
function Girl:init()
-- you can accept and set parameters here
self.position = vec2(0,0)
self.velocity = vec2(0,0)
end
function Girl:jump(power)
sound(SOUND_PICKUP, 44605)
self.velocity = self.velocity + vec2(0,power)
end
function Girl:computeVelocity()
gravity = vec2(Gravity.x, math.min(Gravity.y,-1)):normalize()
gravity = gravity * 15
friction = math.min(self.position.y, 1)
return self.velocity + gravity * friction
end
function Girl:update()
self.position = self.position + self:computeVelocity()
-- Clamp y position
-- (so you don't go through ground)
self.position.y = math.max(self.position.y,0)
-- Clamp x position
self.position.x = math.max(self.position.x,-WIDTH/2)
self.position.x = math.min(self.position.x,WIDTH/2)
-- Dampen velocity
self.velocity = self.velocity * 0.98
end
function Girl:isFalling()
return self:computeVelocity().y < 0
end
function Girl:draw()
self:update()
pushMatrix()
translate(self.position.x, self.position.y)
sprite("Documents:sponge bob", 0, 0)
popMatrix()
end
--# Main
-- Use this function to perform your initial setup
function setup()
print("TAP to JUMP")
print("Tilt your device to land on the clouds!")
print("Press RESET to restart the level")
clouds = CloudLevels()
girl = Girl()
girl.position = vec2(0, 0)
end
-- This function gets called once every frame
function draw()
background(0, 255, 28, 255)
-- displayMode(FULLSCREEN)
-- Center the camera on the girl character
camPos = vec2(WIDTH/2,
math.min(HEIGHT/2 - girl.position.y, 140))
translate(camPos.x,camPos.y)
-- Draw ground
for i = 1,8 do
sprite("Documents:d", -WIDTH/2 -70 + 101*i, -60)
end
clouds:update(camPos)
clouds:draw()
girl:draw()
if clouds:isColliding(girl.position) and
girl:isFalling() then
girl:jump(math.random(30,60))
end
end
function touched(touch)
if touch.tapCount == 1 and
girl.position.y == 0 then
girl:jump(40)
end
end
This is,the hard mode
--# Cloud
Cloud = class()
function Cloud:init()
-- you can accept and set parameters here
self.shapes = {}
self.position = vec2(0,0)
-- Generate random cloud
numCircles = math.random(4, 5)
spacing = 30
for i = 1,numCircles do
x = i * spacing - ((numCircles/2)*spacing)
y = (math.random() - 0.5) * 30
rad = math.random(spacing, 2*spacing)
table.insert(self.shapes, {x=x, y=y, r=rad})
end
self.width = numCircles * spacing + spacing
end
function Cloud:isColliding(pos)
startp = self.position.x - self.width/2
endp = self.position.x + self.width/2
if pos.x < endp and pos.x > startp and
pos.y < (self.position.y + 30) and
pos.y > (self.position.y + 10) then
return true
end
return false
end
function Cloud:draw()
pushStyle()
pushMatrix()
translate(self.position.x, self.position.y)
noStroke()
ellipseMode(RADIUS)
fill(218, 255, 0, 255)
for i,s in ipairs(self.shapes) do
ellipse(s.x, s.y - 5, s.r)
end
fill(184, 255, 0, 255)
for i,s in ipairs(self.shapes) do
ellipse(s.x, s.y + 5, s.r)
end
popMatrix()
popStyle()
end
--# CloudLevels
CloudLevels = class()
CULLPADDING = 300
function CloudLevels:init()
-- you can accept and set parameters here
self.clouds = {}
self.nextCloudHeight = 100
end
function CloudLevels:generateNextCloud()
cloud = Cloud()
cloud.position = vec2(math.random(-WIDTH/2,WIDTH/2),
self.nextCloudHeight)
table.insert(self.clouds, cloud)
self.nextCloudHeight = self.nextCloudHeight + math.random(150,300)
end
function CloudLevels:cullClouds(floor)
for i,v in ipairs(self.clouds) do
if v.position.y < floor then
table.remove(self.clouds,i)
end
end
end
function CloudLevels:isColliding(pos)
for i,v in ipairs(self.clouds) do
if v:isColliding(pos) then
return true
end
end
return false
end
function CloudLevels:update(cam)
curHeight = -cam.y + HEIGHT + CULLPADDING
if curHeight > self.nextCloudHeight then
self:generateNextCloud()
end
self:cullClouds(-cam.y - CULLPADDING)
end
function CloudLevels:draw()
-- Codea does not automatically call this method
for i,v in ipairs(self.clouds) do
v:draw()
end
end
function CloudLevels:touched(touch)
-- Codea does not automatically call this method
end
--# Super_sponge
Girl = class()
function Girl:init()
-- you can accept and set parameters here
self.position = vec2(0,0)
self.velocity = vec2(0,0)
end
function Girl:jump(power)
sound(SOUND_JUMP, 40570)
self.velocity = self.velocity + vec2(0,power)
end
function Girl:computeVelocity()
gravity = vec2(Gravity.x, math.min(Gravity.y,-1)):normalize()
gravity = gravity * 15
friction = math.min(self.position.y, 1)
return self.velocity + gravity * friction
end
function Girl:update()
self.position = self.position + self:computeVelocity()
-- Clamp y position
-- (so you don't go through ground)
self.position.y = math.max(self.position.y,0)
-- Clamp x position
self.position.x = math.max(self.position.x,-WIDTH/2)
self.position.x = math.min(self.position.x,WIDTH/2)
-- Dampen velocity
self.velocity = self.velocity * 0.98
end
function Girl:isFalling()
return self:computeVelocity().y < 0
end
function Girl:draw()
self:update()
pushMatrix()
translate(self.position.x, self.position.y)
sprite("Documents:sponge bob", 0, 0)
popMatrix()
end
--# Main
-- Use this function to perform your initial setup
function setup()
print("TAP to JUMP")
print("Tilt your device to land on the clouds!")
print("Press RESET to restart the level")
clouds = CloudLevels()
girl = Girl()
girl.position = vec2(0, 0)
end
-- This function gets called once every frame
function draw()
background(240, 255, 0, 255)
-- displayMode(FULLSCREEN)
-- Center the camera on the girl character
camPos = vec2(WIDTH/2,
math.min(HEIGHT/2 - girl.position.y, 140))
translate(camPos.x,camPos.y)
-- Draw ground
for i = 1,8 do
sprite("Documents:r", -WIDTH/2 -70 + 101*i, -60)
end
clouds:update(camPos)
clouds:draw()
girl:draw()
if clouds:isColliding(girl.position) and
girl:isFalling() then
girl:jump(math.random(30,60))
end
end
function touched(touch)
if touch.tapCount == 1 and
girl.position.y == 0 then
girl:jump(40)
end
end
If any one want a quation this ismmy email m@abumoosa.com
Or with my imassege m@abumoosa.com
Pleas harry
Hey Mohammad - have a look at my MineSweeper tutorial, this provides code for a simple menu (http://codeatuts.blogspot.com.au/2012/07/tutorial-6-minesweeper-part-1.html), or the Sounds Plus example project included with Codea does this as well.
I see your game it is vary nice i have don all my game and the main menu all things i don it but i cannot make a hayper link from the button to go to the game i want from to make a hayper linke,to my app because,you,have,make a Nice game
Thank you
Pleas i want a a helpe