Hi guys my name is Thomas and I'm new to AppGameKit.

I just made what I think is a working version of Pong. If anyone would like to look at the code and suggest ways for me to improve that would be most helpful. I've not done any programming before besides the original darkbasic when I was 14! It's my new hobby and I'm really enjoying the challenge.

I'm sure everything i've done is probably the worst way to do it, I look forward to any criticisms and learning opportunities.

Thanks for having me

And thanks for making a great trial version of AppGameKit free to use

My next thing will be to try and make a space invaders style game.

SetWindowTitle("Pong")
SetWindowSize( 1024, 768, 1, 0 )
setsyncrate(30,0)
Loadimage(2,"title.png")
createsprite(2,2)
setspritesize(2,50,50)
while getrawkeypressed(13)<>1
PRINT(" WELCOME TO PONG PRESS ENTER TO START")
PRINT("FIRST to 5 is the Winner")
setSpriteposition(2,25,25)
sync()
endwhile
Deletesprite (2)
LoadImage(1,"ballsprite.png")
Createsprite(1,1)
setspritesize(1,5,5)
setspriteshape(1,2)
SetSpriteAnimation(1,32,32,6)
ballposx=50
ballposy=50
spin=1
oldspin=1
Loadimage(3,"player.png")
createsprite(3,3)
setspritesize(3,10,10)
Setspriteshape(3,2)
SetSpriteFlip (3,0,1)
playerposx=50
playerposy=1
SetSpritePosition(3,playerposx,playerposy)
createsprite(4,3)
compposx=50
compposy=90
setspritesize(4,10,10)
Setspriteshape(4,2)
SetSpritePosition(4,compposx,compposy)
move=0
ballpath=1
compscore=0
playerscore=0
do
oldspin=spin
move=0
if GetRawKeyPressed(37) then move=1
if GetRawKeyPressed(39) then move=2
If move=1 then gosub _left
if move=2 then gosub _right
SetSpritePosition(4,compposx,compposy)
SetSpritePosition(3,playerposx,playerposy)
SetSpritePosition(1,ballposx,ballposy)
// Ball paths 1=straight down 2= straight up 3=down to right 4=Up to left 5=up to right 6=down to left
// Sprite 1 is the ball Sprite 4 computer on bottom sprite 3 player on top
if getspritecollision(1,4)=1
spin=spin+1
if compposx<>ballposx
If compposx>ballposx
if ballpath=6 then ballpath=4
if ballpath=3 then ballpath=2
if ballpath=1 then ballpath=4
elseif compposx<ballposx
if ballpath=1 then ballpath=5
if ballpath=3 then ballpath=5
if ballpath=6 then ballpath=2
endif
elseif compposx=ballposx
if ballpath=1 then ballpath=2
if ballpath=6 then ballpath=4
if ballpath=3 then ballpath=5
endif
endif
// Ball paths 1=straight down 2= straight up 3=down to right 4=Up to left 5=up to right 6=down to left
// Sprite 1 is the ball Sprite 4 computer on bottom sprite 3 player on top
// Playerpos greater than ball than player is to the right of the ball
// Playerpos less than ball than player is to the left of the ball
if getspritecollision(1,3)=1
spin=spin+1
if playerposx<>ballposx
If playerposx>ballposx
if ballpath=2 then ballpath=6
if ballpath=4 then ballpath=6
if ballpath=5 then ballpath=1
elseif playerposx<ballposx
if ballpath=2 then ballpath=3
if ballpath=4 then ballpath=1
if ballpath=5 then ballpath=3
endif
elseif playerposx=ballposx
if ballpath=2 then ballpath=1
if ballpath=4 then ballpath=6
if ballpath=5 then ballpath=3
endif
endif
If ballposx<5
If ballpath=3 then ballpath=4
endif
If ballposx>95
if ballpath=4 then ballpath=3
endif
Gosub _ballpath
Gosub _compmove
if oldspin<>spin then gosub _Topspin
if compscore>4 then gosub _compwin
If playerscore>4 then gosub _playerwin
if getrawkeypressed(27)=1 then Exit
Print ("playerscore")
Print (playerscore)
Print ("compscore")
Print (compscore)
Sync()
loop
_Topspin:
if ballpath=1 then spin=1
if ballpath=2 then spin=4
if ballpath=3 then spin=3
if ballpath=4 then spin=4
if ballpath=5 then spin=3
if ballpath=6 then spin=4
if spin=1 then Playsprite(1,10,1,4,6)
if spin=2 then Playsprite(1,10,1,1,3)
if spin=3 then Playsprite(1,10,1,3,1)
if spin=4 then Playsprite(1,10,1,6,4)
return
_ballpath:
// Ball paths 1=straight down 2= straight up 3=down to right 4=Up to left 5=up to right 6=down to left
If ballpath=1 then ballposy=ballposy+3
if ballpath=2 then ballposy=ballposy-3
if ballpath=3
ballposy=ballposy+2
ballposx=ballposx+2
endif
if ballpath=4
ballposy=ballposy-2
ballposx=ballposx-2
endif
if ballpath=5
ballposy=ballposy-2
ballposx=ballposx+2
endif
if ballpath=6
ballposy=ballposy+2
ballposx=ballposx-2
endif
// change ballpath if x approaches boundary
// Ball paths 1=straight down 2= straight up 3=down to right 4=Up to left 5=up to right 6=down to left
if ballposx<5
ballposx=ballposx+2
if ballpath=4 then ballpath=5
If ballpath=6 then ballpath=3
elseif ballposx>95
ballposx=ballposx-2
if ballpath=5 then ballpath=4
if ballpath=3 then ballpath=6
endif
if ballposy<10
Compscore = Compscore +1
Ballpath=1
Playerposx=50
ballposx=50
Compposx=50
endif
If ballposy>90
Playerscore=playerscore+1
Ballpath=2
Playerposx=50
Compposx=50
ballposx=50
endif
return
_left:
playerposx=playerposx-5
if playerpos<5 then playerpos=5
return
_right:
playerposx=playerposx+5
if playerpos>95 then playerpos=95
return
_compmove:
If ballposx>compposx
compposx=compposx+1
Elseif ballposx<compposx
compposx=compposx-1
endif
return
_compwin:
Playerposx=50
playerposy=1
ballposy=50
balllposx=50
compposy=90
Compposx=50
compscore=0
Playerscore=0
ballpath=1
while getrawkeypressed(13)<>1
PRINT("YOU LOST. GOOD TRY. PONG PRESS ENTER TO START")
PRINT("FIRST to 5 is the Winner")
if getrawkeypressed(27)=1 then Exit
setSpriteposition(2,25,25)
sync()
endwhile
return
_playerwin:
Playerposx=50
playerposy=1
ballposy=50
balllposx=50
compposy=90
Compposx=50
compscore=0
Playerscore=0
ballpath=1
while getrawkeypressed(13)<>1
PRINT("YOU WIN! PONG PRESS ENTER TO START AGAIN")
PRINT("FIRST to 5 is the Winner")
if getrawkeypressed(27)=1 then Exit
setSpriteposition(2,25,25)
sync()
endwhile
return[img]null[/img]