Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Longboard Skert

edited January 2015 Posts: 1

Here is the code for a new game I am creating. Please tell me what you think of it. Any suggestions would be great.

function setup() bird= physics.body (CIRCLE,25) bird.position=vec2(300,500) bird.x=385 bird.y=3/4*HEIGHT bird.gravityScale=0 xt=-1 yt=0 xspeed=10 xl=0 yl=HEIGHT xl2=WIDTH yl2=HEIGHT rx=124 r2x=210 r3x=297 r4x=385 r5x=472 r6x=558 r7x=645 ry=HEIGHT/5 r2y=math.random(-HEIGHT,0) r3y=math.random(-HEIGHT,0) r4y=math.random(-HEIGHT,0) r5y=math.random(-HEIGHT,0) r6y=math.random(-HEIGHT,0) r7y=math.random(-HEIGHT,0) rheight=150 rwidth=78 rspeed=200 ewidth=140 eheight=200 esize=10 gx=WIDTH/2 gy=HEIGHT/2 gy2=-HEIGHT/2 cspeed=math.random(8,20) cspeed2=math.random(8,20) cspeed3=math.random(8,20) cspeed4=math.random(8,20) cspeed5=math.random(8,20) cspeed6=math.random(8,20) cspeed7=math.random(8,20) scores=0 fastcar="Documents:fast car3" car2="Documents:car2" car3="Documents:car2" car4="Documents:car2" car5="Documents:car2" car6="Documents:car2" car7="Documents:car2" colx=5 coly=10 end function draw() background(40, 40, 50) sprite("Documents:gme bk",gx,gy,WIDTH,HEIGHT+20) sprite("Documents:gme bk",gx,gy2,WIDTH,HEIGHT+20) sprite("Documents:car2",rx,ry,rwidth,rheight) sprite(car2,r2x,r2y,rwidth,rheight) sprite(car3,r3x,r3y,rwidth,rheight) sprite(car4,r4x,r4y,rwidth,rheight) sprite(car5,r5x,r5y,rwidth,rheight) sprite(car6,r6x,r6y,rwidth,rheight) sprite(car7,r7x,r7y,rwidth,rheight) sprite("Documents:color board",bird.x,bird.y,ewidth,eheight) if xt>=0 and yt>=0 then ry=ry+cspeed r2y=r2y+cspeed2 r3y=r3y+cspeed3 r4y=r4y+cspeed4 r5y=r5y+cspeed5 r6y=r6y+cspeed6 r7y=r7y+cspeed7 gy=gy+7 gy2=gy2+7 scores=scores if gy>=HEIGHT/2+HEIGHT then gy=-HEIGHT/2 end if gy2>=HEIGHT/2+HEIGHT then gy2=-HEIGHT/2 end if CurrentTouch.state == BEGAN then if xt<=WIDTH/2 then if bird.x>=100 then bird.x=bird.x-xspeed end end if xt>=WIDTH/2 then if bird.x<=WIDTH-100 then bird.x=bird.x+xspeed end end end if CurrentTouch.state == MOVING then if xt<=WIDTH/2 then if bird.x>=100 then bird.x=bird.x-xspeed end end if xt>=WIDTH/2 then if bird.x<=WIDTH-100 then bird.x=bird.x+xspeed end end end if ry>=HEIGHT then ry=math.random(-HEIGHT,0) cspeed=math.random(8,20) end if r2y>=HEIGHT then r2y=math.random(-HEIGHT,0) cspeed2=math.random(8,20) end if r3y>=HEIGHT then r3y=math.random(-HEIGHT,0) cspeed3=math.random(8,20) end if r4y>=HEIGHT then r4y=math.random(-HEIGHT,0) cspeed4=math.random(8,20) end if r5y>=HEIGHT then r5y=math.random(-HEIGHT,0) cspeed5=math.random(8,20) end if r6y>=HEIGHT then r6y=math.random(-HEIGHT,0) cspeed6=math.random(8,20) end if r7y>=HEIGHT then r7y=math.random(-HEIGHT,0) cspeed7=math.random(8,20) end if bird.x>=rx-rwidth/2-colx and bird.x<=rx+rwidth/2+colx and bird.y>=ry-coly-rheight/2 and bird.y<=ry+rheight/2+coly then restart() end if bird.x>=r2x-rwidth/2-colx and bird.x<=r2x+rwidth/2+colx and bird.y>=r2y-coly-rheight/2 and bird.y<=r2y+rheight/2+coly then restart() end if bird.x>=r3x-rwidth/2-colx and bird.x<=r3x+rwidth/2+colx and bird.y>=r3y-coly-rheight/2 and bird.y<=r3y+rheight/2+coly then restart() end if bird.x>=r4x-rwidth/2-colx and bird.x<=r4x+rwidth/2+colx and bird.y>=r4y-coly-rheight/2 and bird.y<=r4y+rheight/2+coly then restart() end if bird.x>=r5x-rwidth/2-colx and bird.x<=r5x+rwidth/2+colx and bird.y>=r5y-coly-rheight/2 and bird.y<=r5y+rheight/2+coly then restart() end if bird.x>=r6x-rwidth/2-colx and bird.x<=r6x+rwidth/2+colx and bird.y>=r6y-coly-rheight/2 and bird.y<=r6y+rheight/2+coly then restart() end if bird.x>=r7x-rwidth/2-colx and bird.x<=r7x+rwidth/2+colx and bird.y>=r7y-coly-rheight/2 and bird.y<=r7y+rheight/2+coly then restart() end if cspeed2>=18 then car2=fastcar end if cspeed2<18 then car2="Documents:car2" end if cspeed3>=18 then car3=fastcar end if cspeed3<18 then car3="Documents:car2" end if cspeed4>=18 then car4=fastcar end if cspeed4<18 then car4="Documents:car2" end if cspeed5>=18 then car5=fastcar end if cspeed5<18 then car5="Documents:car2" end if cspeed6>=18 then car6=fastcar end if cspeed6<18 then car6="Documents:car2" end if cspeed7>=18 then car7=fastcar end if cspeed7<18 then car7="Documents:car2" end strokeWidth(5) end end function touched(touch) xt = touch.x yt = touch.y end
Tagged:

• Posts: 835

We dont have your documents, so we cant play your game

• edited January 2015 Posts: 7,810

@jgarsk It's hard to run your program because any sprite you use from your documents folder isn't available to anyone on the forum. So when we run your code, none of your sprites show. It's advisable that any games you want to share on the forum should use the sprites from the assets pack included with Codea.

• Posts: 2,042

@jgarsk, it'd be nice if you included an image loader so we can all have your images and really play it the way it was meant.

• Posts: 7,810

@jgarsk You could replace your code above using Codea sprites even if they aren't exactly what you have in mind.

• Posts: 5,396

@jgarsk - you will find it much easier to program if you learn how to use tables. This post shows why tables are so useful.

https://coolcodea.wordpress.com/2014/10/01/169-why-tables-and-classes-are-so-useful/

• edited January 2015 Posts: 136

@jgarsk and for loops. They go hand in hand with tables a lot of the time here-
http://www.lua.org/pil/4.3.4.html
but really just focus on the basic for loop-

for i = 0, x do

end

where x is how many times you want to do it, and i is how many times the loop has been itterated.