Yes you can..
Menu: (thanks to n3wton)
// Menu DBA
Function MenuLoop()
Logo = find free image()
Load Image "MediaTillylogo.png", Logo
Sprite Logo, 0, 0, Logo
Hide Sprite Logo
Load Music "MediaTillyTheme.mid", 1
Play Music 1
for x = 1 to 20
xp = (Screen Width()/2)-(image width(Logo)/2)
yp = (Screen Height()/2)-(image Height(Logo)/2)
Paste Sprite Logo, xp-20+rnd(40), yp-20+rnd(40)
Sync
Wait 50
next x
for x = 1 to 20
xp = (Screen Width()/2)-(image width(Logo)/2)
yp = (Screen Height()/2)-(image Height(Logo)/2)
Paste Sprite Logo, xp-10+rnd(20), yp-10+rnd(20)
Sync
Wait 50
next x
for x = 1 to 20
xp = (Screen Width()/2)-(image width(Logo)/2)
yp = (Screen Height()/2)-(image Height(Logo)/2)
Paste Sprite Logo, xp-2+rnd(4), yp-2+rnd(4)
Sync
Wait 50
next x
for x = 1 to 255 step 4
Paste Sprite Logo, (Screen Width()/2)-(image width(Logo)/2), (Screen Height()/2)-(image Height(Logo)/2)
Set Sprite Alpha Logo, 255 - x
Sync
next x
wait 3000
Stop Music 1
Delete Music 1
Load Music "MediaTheme.mid", 1
Load Sound "MediaDing.wav", 2
Loop Music 1
BGR = find free image()
Load Image "MediaPongBGR.png", BGR
Sprite BGR, 0, 0, BGR
Size Sprite BGR, Screen Width(), Screen Height()
Hide Sprite BGR
Set Text Size 32
Set Text Font "Fixedsys"
Do
Paste Sprite BGR, 0, 0
if InBox( (Screen Width()/2)-(Text Width("Start")/2), (Screen Height()/1.8), (Screen Width()/2)+(Text Width("Start")/2), (Screen Height()/1.8)+(Text Height("Start")) )
ink Rgb(255,255,0), 0
if onplay = 0 then Stop Sound 2 : Play Sound 2
onplay = 1
if mouseclick() = 1
While MouseClick() = 1
endWhile
Stop Music 1
Exit
endif
else
onplay = 0
endif
Center Text Screen Width()/2, Screen Height()/1.8, "Start"
ink rgb(255, 255, 255), 0
if InBox( (Screen Width()/2)-(Text Width("Start")/2), (Screen Height()/1.8)+(Text Height("ABCD")*2), (Screen Width()/2)+(Text Width("Start")/2), (Screen Height()/1.8)+(Text Height("Start"))+(Text Height("ABCD")*2) )
ink Rgb(255,255,0), 0
if onexit = 0 then Stop Sound 2 : Play Sound 2
onexit = 1
if mouseclick() = 1
While MouseClick() = 1
endWhile
Stop Music 1
End
endif
else
onexit = 0
endif
Center Text Screen Width()/2, (Screen Height()/1.8)+(Text Height("ABCD")*2), "Exit"
ink rgb(255, 255, 255), 0
Sync
Loop
endFunction
Function InBox( x1, y1, x2, y2 )
mx = MouseX()
my = MouseY()
if (mx >= x1) and (mx <= x2) and (my >= y1) and (my <= y2) then result = 1 else result = 0
endFunction result
Game:
Function GameLoop()
Hide Mouse
Global P1S, P2S as integer
Global across as integer
Global iscol as integer
Global dim wall(4) as integer
Dim Player(2) as paddle
Player(1).id = MakePlayer(0, 0, -100)
Player(1).lb = MakeLeftBox(1)
Player(1).rb = MakeRightBox(1)
Player(2).id = MakePlayer(0, 0, 100)
Player(2).lb = MakeLeftBox(2)
Player(2).rb = MakeRightBox(2)
Ball = MakeBall()
MakeWorld()
iscol = 0
Load Audio 1, "media/pong.wav"
Position Camera 0, 200, 0
Point Camera 0, 0, 0
Direction# = -1 + rnd(2)
Across = -4 + rnd(8)
if Direction# = 0 then Direction# = 1
if Across = 0 then Across = 2
cls
Center Text Screen Width()/2, (Screen Height()/2)-text Height("Player One Use A and D"), "Player One Use A and D"
Center Text Screen Width()/2, Screen Height()/2, "Player Two Use LeftArrow and RightArrow"
Center Text Screen Width()/2, (Screen Height()/2)+text Height("Press Anykey..."), "Press Anykey..."
Sync
Wait Key
Set Text Size 112
Do
// Control Player 1 with A and D
if keystate(30)
if Object Position X(Player(1).id) > -68 then Move Object Left Player(1).id, 4
endif
if keystate(32)
if Object Position X(Player(1).id) < 68 then Move Object Right Player(1).id, 4
endif
// Control Player 2 with left and right
if LeftKey()
if Object Position X(Player(2).id) > -68 then Move Object Left Player(2).id, 4
endif
if RightKey()
if Object Position X(Player(2).id) < 68 then Move Object Right Player(2).id, 4
endif
For x = 1 to 2
Position Object Player(x).rb, Object Position X(Player(x).id)+15.5, Object Position Y(Player(x).id), Object Position Z(Player(x).id)
Position Object Player(x).lb, Object Position X(Player(x).id)-15.5, Object Position Y(Player(x).id), Object Position Z(Player(x).id)
Sc_UpdateObject Player(x).rb
Sc_UpdateObject Player(x).lb
Sc_UpdateObject Player(x).id
Next x
// Move Ball
Direction# = MoveBall(ball, Direction#, Player(1).id, Player(2).id)
//Score
text 0, 0, str$(P2S)
text 0, Screen Height() - Text Height(str$(P1S)), Str$(P1S)
if P1S = 5
Set Text Size 50
Center Text Screen Width() / 2, Screen Height() / 5, "Player 1 Wins!"
Set Text Size 32
Center Text Screen Width() / 2, Screen Height() / 2, "Press any key to continue"
Sync
Wait Key
Set Text Size 112
Direction# = -4 + rnd(8)
Across = -4 + rnd(8)
if Direction# = 0 then Direction# = 2
if Across = 0 then Across = 2
P1s = 0 : P2S = 0
endif
if P2S = 5
Set Text Size 50
Center Text Screen Width() / 2, Screen Height() / 5, "Player 2 Wins!"
Set Text Size 32
Center Text Screen Width() / 2, Screen Height() / 2, "Press any key to continue"
Sync
Wait Key
Set Text Size 112
Direction# = -4 + rnd(8)
Across = -4 + rnd(8)
if Direction# = 0 then Direction# = 2
if Across = 0 then Across = 2
P1S = 0 : P2S = 0
endif
Sync
Loop
endFunction
Function MakePlayer(x, y, z)
obj = Find Free Object()
Make Object Box obj, 30, 10, 2
Position Object obj, x, y, z
Sc_SetUpObject obj, 1, 0
endFunction obj
Function MakeWorld()
obj = Find Free Object()
Make Object Box obj, 2, 2, 220
Position Object obj, -87, 0, 0
Set Alpha Mapping On obj, 20
Wall(1) = obj
Sc_SetUpObject obj, 1, 0
obj = Find Free Object()
Make Object Box obj, 2, 2, 220
Position Object obj, 87, 0, 0
Set Alpha Mapping On obj, 20
Wall(2) = obj
Sc_SetUpObject obj, 1, 0
obj = Find Free Object()
Make Object Box obj, 176, 2, 2
Position Object obj, 0, 0, 110
Set Alpha Mapping On obj, 20
Wall(3) = obj
Sc_SetUpObject obj, 1, 0
obj = Find Free Object()
Make Object Box obj, 176, 2, 2
Position Object obj, 0, 0, -110
Set Alpha Mapping On obj, 20
Wall(4) = obj
Sc_SetUpObject obj, 1, 0
endfunction
Function MakeBall()
obj = Find Free Object()
Make Object Sphere obj, 10
Sc_SetUpObject obj, 1, 1
endFunction obj
Function MoveBall(obj, Direction#, P1, P2)
Move Object obj, Direction#
Move Object Left obj, across
Sc_UpdateObject obj
if Sc_ObjectCollision(obj, 0) = P1 or Sc_ObjectCollision(obj, 0) = P2
if iscol = 0 or iscol = 2
Direction# = Direction# * -1.1
If Audio Playing(1) then Stop Audio 1
Play Audio 1
iscol = 1
endif
else
if Sc_ObjectCollision(obj, 0) = Wall(3) or Sc_ObjectCollision(obj, 0) = Wall(4)
if Direction# < 0 then inc P2S, 1 else inc P1S, 1
Position Object obj, 0, 0, 0
Direction# = -4 + rnd(8)
if Direction# = 0 then Direction# = 2
else
if Sc_ObjectCollision(obj, 0) > 0
if Sc_ObjectCollision(obj, 0) = Wall(1) or Sc_ObjectCollision(obj, 0) = Wall(2)
Across = Across * -1
else
if iscol = 0
Across = Across * -1
iscol = 2
endif
endif
If Audio Playing(1) then Stop Audio 1
Play Audio 1
else
iscol = 0
endif
endif
endif
endFunction Direction#
Function MakeLeftBox(x)
obj = Find Free Object()
Make Object Box obj, 1, 10, 5
Position Object obj, Object Position X(Player(x).id)-15.5, Object Position Y(Player(x).id), Object Position Z(Player(x).id)
Sc_SetUpObject obj, 1, 0
endFunction obj
Function MakeRightBox(x)
obj = Find Free Object()
Make Object Box obj, 1, 10, 5
Position Object obj, Object Position X(Player(x).id)+15.5, Object Position Y(Player(x).id), Object Position Z(Player(x).id)
Sc_SetUpObject obj, 1, 0
endFunction obj
