I have tried to make a Pong Game but there are some Problem zones with Control Up down Keys and the Ball Sphäre Cube behaviour.. I am using consoleG and Controlpanels ... Perhaps Charles can have a closer Look at the Code many thanks
See Post 2
Update:
% Title "The Pong Game"
% Animated
% PlaceCentral
uses ConsoleG
uses ControlPanels
type tPlayer
score as long
paddlePos as single
end type
dim Player1 as tPlayer
dim Player2 as tPlayer
type tBall
X as single
Y as single
R as byte
G as byte
B as byte
XSpin as long
YSpin as long
end type
sub main
========
'cls 0.0, 0.2, 0.7
cls 0.0, 0.2, 0.7
pushstate
'move 0,-.5
move -19.0,14.5
scale 2
printl "Pong"
popstate
pushState
color .20,.80,.00,.88
'gltranslatef -16.5, 2.40, -1
move -8.0,14.5
scale 1
print "Player 1: "+str(Player1.score)
'gltranslatef -5.25, -1.40, -1
popstate
pushState
move -1.0,14.5
scale 1
print "Player 2: "+str(Player2.score)
popstate
shading
scale 3
pushstate
Material Gold
static float ang
rotateX ang
rotateY ang
'scale 1,3,4
scale 1,1,1
'go cube
go sphere
popstate
'-----------------------------
dim ball as tBall
ball.xspin = 1
ball.yspin = 1
type tBall
x as single
y as single
r as byte
g as byte
b as byte
xspin as long
yspin as long
end type
static int framecounter
framecounter++
' bouncing ball if too high
if ball.y > 2.5 then
ball.yspin = -1
ball.y = 2.5
end if
if ball.y <-2.5 then
ball.yspin = 1
ball.y = -2.5
end if
if ball.x < -4.5 then
ball.xspin = -ball.xspin
ball.x = -4.5
if ball.y < Player1.paddlePos + 0.5 and ball.y > Player1.paddlePos - 0.5 then
Player1.score += 10
else
Player2.score += 10
end if
end if
if ball.x > 4.5 then
ball.xspin = -ball.xspin
ball.x = 4.5
if ball.y < Player2.paddlePos + 0.5 and ball.y > Player2.paddlePos - 0.5 then
Player2.score += 10
else
Player1.score += 10
end if
end if
ball.x = ball.x + 2.9 * ball.xspin / framecounter
ball.y = ball.y + 2.9 * ball.yspin / framecounter
ball.R = 128+cos(GetTickCount/1000)*127
ball.G = 128+cos(GetTickCount/1500)*127
ball.B = 128+cos(GetTickCount/2000)*127
gltranslatef 0,0,-10
glColor3f 255, 255,255
pushstate
static float ang
gltranslatef -10, Player1.paddlePos, 0
scale 0.5,3.5,2
go cube
popstate
popstate
gltranslatef 10, Player2.paddlePos, 0
scale 0.5,3.5,2
go cube
popstate
popstate
gltranslatef ball.x, ball.y, 0
glcolor3f ball.r, ball.g, ball.b
scale 1,1,1
go sphere
popstate
'----------------------- problem: up or down key ----------------------- //
'up = 38, down 40 '%VK_UP
if lastkey(38) then
Player2.paddlePos += 10 / framecounter
if Player2.paddlePos > 2.5 then Player2.paddlePos = 2.5
elseif lastkey(40) then '%VK_DOWN
Player2.paddlePos -= 10 / framecounter
if Player2.paddlePos <-2.5 then Player2.paddlePos =-2.5
end if
'----------------------- problem: up or down key ----------------------- //
'game end:
if Player1.score = 150 then
print "Player1. wins ! - Game over"
elseif Player2.score = 150 then
print "Player2. wins ! - game over"
end if
'-----------------------------
ang+=.5 : if ang>=360 then ang-=360
end sub
EndScript
Wait dear Charles I will manage IT Alone :)
Found one Problem solution and solve it and will try more to find right solution
'----------------------- problem: up or down key ----------------------- //
'up = 38, down 40 '%VK_UP
if lastkey then
gprint lastkey() +"key 38: "
Player2.paddlePos += 10 / framecounter
if Player2.paddlePos > 4.5 then Player2.paddlePos = 4.5
end if
if lastkey=%VK_DOWN then '%VK_DOWN
gprint lastkey() +"key 40: "
Player2.paddlePos -= 100 / framecounter
if Player2.paddlePos <-4.5 then Player2.paddlePos =-4.5
end if
'end if
'----------------------- problem: up or down key ----------------------- //
No way sorry dont understand how to bounce or move the Ball / Sphere across the Scene.. tried IT with framecounter gettickcount etcpp ... I have No Idea how to bind the Sphere to the ball.x ball.y running... Now Help is Welcome :)
% Title "The Pong Game"
% Animated
% PlaceCentral
uses ConsoleG
uses ControlPanels
$ fontA = "Arial",FW_SEMIBOLD
macro keydown
case 27 : 'no action
case 32 : 'no action
end macro
type tPlayer
score as long
paddlePos as single
end type
dim Player1 as tPlayer
dim Player2 as tPlayer
type tBall
X as single
Y as single
R as byte
G as byte
B as byte
XSpin as long
YSpin as long
end type
sub main
========
cls 0.0, 0.2, 0.7
pushstate
'move 0,-.5
move -19.0,14.5
scale 2
printl "Pong"
popstate
pushState
color .20,.80,.00,.88
'gltranslatef -16.5, 2.40, -1
move -8.0,14.5
scale 1
print "Player 1: "+str(Player1.score)
'gltranslatef -5.25, -1.40, -1
popstate
pushState
move -1.0,14.5
scale 1
print "Player 2: "+str(Player2.score)
popstate
shading
scale 3
pushstate
Material Gold
static float ang
rotateX ang
rotateY ang
'scale 1,3,4
scale 1,1,1
'go cube
'go sphere
popstate
'int x,y,cx,cy,speed,size,color
'ball(x,y,cx,cy,speed,color)
'-----------------------------
dim ball as tBall
ball.xspin += 1
ball.yspin += 1
type tBall
x as single
y as single
r as byte
g as byte
b as byte
xspin as long
yspin as long
end type
static int framecounter
framecounter++
' bouncing ball if too high
if ball.y > 4.5 then
ball.yspin = -1
ball.y = 4.5
end if
if ball.y <-4.5 then
ball.yspin = 1
ball.y = -4.5
end if
if ball.x < -4.5 then
ball.xspin = -ball.xspin
ball.x = -4.5
if ball.y < Player1.paddlePos + 0.5 and ball.y > Player1.paddlePos - 0.5 then
Player1.score += 10
else
Player2.score += 10
end if
end if
if ball.x > 4.5 then
ball.xspin = -ball.xspin
ball.x = 4.5
if ball.y < Player2.paddlePos + 0.5 and ball.y > Player2.paddlePos - 0.5 then
Player2.score += 10
else
Player1.score += 10
end if
end if
dim ball as tBall
ball.xspin += 1
ball.yspin += 1
'----------------- problem zone 2 --------------- // ball+sphere
'ball.x = ball.x + 40.9 * ball.xspin / 128+sin(GetTickCount/100) 'framecounter
'ball.y = ball.y + 40.9 * ball.yspin / 128+cos(GetTickCount/100) 'framecounter
ball.x = ball.x + 40.9 * ball.xspin / framecounter
ball.y = ball.y + 40.9 * ball.yspin / framecounter
'ball.R = 128+cos(GetTickCount/1000)*127
'ball.G = 128+cos(GetTickCount/1500)*127
'ball.B = 128+cos(GetTickCount/2000)*127
gltranslatef 0,0,-10
glColor3f 255, 255,255
pushstate
static float ang
gltranslatef -10, Player1.paddlePos, 0
scale 0.5,3.5,2
go cube
popstate
popstate
gltranslatef 10, Player2.paddlePos, 0
scale 0.5,3.5,2
go cube
popstate
''popstate
'' glTranslatef -10+ball.x, ball.y, 0
'' 'glColor3f ball.r, ball.g, ball.b
'' scale 2.5,0.5,0.5
'' go sphere
''popstate
'cls 0.0, 0.2, 0.7
float x,y,z
x=1 : y=1 : z=6
shading
scale 3.0,0.5,0.5 '10
pushstate
Material Gold
'move(-10,1,0)
gltranslatef(-10+ball.x,ball.y,0)
'rotatexy(1,1,1)
'go sphere
'go spheric(1,1,6)
go spheric(x,y,z)
'go spheric(ball.xspin,ball.yspin,z)
popstate
'-----------------------------------------------------------------------
''glClearColor 0.5, 0.5, 0.7, 0
''glPushMatrix
''gltranslatef -15.0,0.0,-1.0
''glscalef 1.25,.3,.01
''glColor3f .99,.99,.00
''gprint "Last key pressed: "
''glColor3f .99,.99,.99
''if lastkey
'' gprint lastkey() " = 0x" hex(lastkey)
''else
'' gprint "(none)"
''end if
''glPopMatrix
'-------------------------------------------------------------------------
'----------------------- problem: up or down key ----------------------- //
'up = 38, down 40 '%VK_UP
if lastkey then
gprint lastkey(%VK_UP) +"key 38: "
Player2.paddlePos += 20 / framecounter
if Player2.paddlePos > 4.5 then Player2.paddlePos = 4.5
end if
if lastkey=%VK_DOWN then '%VK_DOWN
gprint lastkey() +"key 40: "
Player2.paddlePos -= 100 / framecounter
if Player2.paddlePos <-4.5 then Player2.paddlePos =-4.5
end if
'end if
'up = 38, down 40 '%VK_UP
if lastkey then
gprint lastkey() +"key 38: "
Player1.paddlePos += 20 / framecounter
if Player1.paddlePos > 4.5 then Player1.paddlePos = 4.5
end if
if lastkey=%VK_DOWN then '%VK_DOWN
gprint lastkey() +"key 40: "
Player1.paddlePos -= 100 / framecounter
if Player1.paddlePos <-4.5 then Player1.paddlePos =-4.5
end if
'end if
'---
'----------------------- problem: up or down key ----------------------- //
'game end:
if Player1.score = 150 then
print "Player1. wins ! - Game over"
elseif Player2.score = 150 then
print "Player2. wins ! - game over"
end if
'-----------------------------
ang+=.5 : if ang>=360 then ang-=360
end sub
EndScript
Hi Frank,
I think a new structure is needed for games of this genre. Here is a Pong base with boundaries and a bouncing ball. It is very simple so you can see how the dynamics are generated.
#compact
% filename "t.exe"
'uses RTL32
% Title "PONG BASE"
% Animated
% ScaleUp
% PlaceCentral
'% AnchorCentral
uses ConsoleG
indexbase 1
'sys sseed=GetTickCount
sub main()
==========
'
'static float ay
'static sys pki,count
glClearColor 0,0.20,0,0
if not pick
thickness 3
color .99,0,0
glbegin GL_LINES
if opening
static float byl=10
static float bxl=15
static float byd=11
static float bxd=16
endif
'
glvertex3f -bxd,-byd,0
glvertex3f bxd,-byd,0
'
glvertex3f -bxd,byd,0
glvertex3f bxd,byd,0
'
glvertex3f -bxd,-byd,0
glvertex3f -bxd,byd,0
'
glvertex3f bxd,-byd,0
glvertex3f bxd,byd,0
'
glend
'
shading
color .90,.90,0
static float blx,bly
static float vlx,vly
if opening
vlx=0.1
vly=0.05
endif
'
pushstate
move blx,bly
go sphere
blx+=vlx
bly+=vly
'
'LIMIT AND BOUNCE
'
if blx > bxl
vlx = -vlx
elseif blx<-bxl
vlx = -vlx
endif
'
if bly>byl
vly = -vly
elseif bly < -byl
vly = -vly
endif
'
popstate
'
end if
'
end sub
EndScript
Single player Pong with score:
#compact
% filename "t.exe"
'uses RTL32
% Title "PONG BASE 2"
% Animated
% ScaleUp
% PlaceCentral
'% AnchorCentral
uses ConsoleG
indexbase 0
'sys sseed=GetTickCount
sub main()
==========
'
'static float ay
'static sys pki,count
glClearColor 0,0.20,0,0
if not pick
thickness 3
if opening
static float byl=10
static float bxl=15
static float byd=11
static float bxd=16
endif
'
flat
color .99,0,0
glbegin GL_LINES
glvertex3f -bxd,-byd,0
glvertex3f bxd,-byd,0
'
glvertex3f -bxd,byd,0
glvertex3f bxd,byd,0
'
glvertex3f -bxd,-byd,0
glvertex3f -bxd,byd,0
'
glvertex3f bxd,-byd,0
glvertex3f bxd,byd,0
'
glend
'
shading
color .90,.90,0
static float blx,bly
static float vlx,vly
static int tal,ntal
if opening
vlx=0.2
vly=0.1
endif
'
pushstate
move blx,bly
go sphere 'radius 0.5
popstate
blx+=vlx
bly+=vly
'
'LIMIT AND BOUNCE
'
if blx > bxl
vlx = -vlx
ntal++
elseif blx<-bxl
vlx = -vlx
endif
'
if bly>byl
vly = -vly
elseif bly < -byl
vly = -vly
endif
'
'PONG BAT AND SCORE
'
if opening
static float btu=2.0
static float btx=bxl-2.0
static float bty=0.0
endif
'pong impact
if blx>=btx-1.0
if vlx<0.0
'bouncing behind bat
elseif bly>bty+btu+0.5
'above bat
elseif bly<bty-btu-0.5
'below bat
else
tal++
vlx = -vlx
endif
endif
'SCORE
flat
pushstate
move -bxd,byd+1.0
scale 2
print str(tal)" / "+str(ntal)
popstate
'
'
'pong bat render
pushstate
glbegin GL_QUADS
glvertex3f btx-0.25,bty-btu,0
glvertex3f btx+0.25,bty-btu,0
glvertex3f btx+0.25,bty+btu,0
glvertex3f btx-0.25,bty+btu,0
glend
popstate
'
end if
'
'KEYBOARD CONTROL
if GetAsyncKeyState VK_UP
if byd>bty+btu 'limit
bty+=0.1
endif
endif
if GetAsyncKeyState VK_DOWN
if -byd < bty-btu
bty-=0.1
endif
endif
'
end sub
EndScript
Good solution Charles many thanks! :)
I nearly understand all your working with Cube / Quad creation for the Paddle and new for me was also the opening command ;)
I have to learn much more about collision..
Thanks Frank
Good evening... How I can Run both paddles working with the Sphere? I have used your example Charles but Made my own example with left Paddle running. Both paddles dont Run as wished See my Problemzone I have marked thanks frank
#compact
'uses RTL32
% Title "PONG BASE 2a"
% Animated
% ScaleUp
% PlaceCentral
'% AnchorCentral
uses ConsoleG
indexbase 0
sub main()
==========
'
'static float ay
'static sys pki,count
glClearColor 0,0.20,0,0
if not pick
thickness 3
if opening
static float byllim=11 'bwlimit rahmen für kugel
static float bxllim=16 'bwlimit rahmen für kugel
static float rahbyd=12 'unten-rax oben-links-rechts
static float rahbxd=17 'unten-ray oben-links-rechts
endif
'
flat
color .99,0,0
glbegin GL_LINES
glvertex3f -rahbxd,-rahbyd,0 'rahmen-unten
glvertex3f rahbxd,-rahbyd,0 'rahmen-unten
'
glvertex3f -rahbxd,rahbyd,0 'rahmen-oben
glvertex3f rahbxd,rahbyd,0 'rahmen-oben
'
glvertex3f -rahbxd,-rahbyd,0 'rahmen-links
glvertex3f -rahbxd,rahbyd,0 'rahmen-links
'
glvertex3f rahbxd,-rahbyd,0 'rahmen-rechts
glvertex3f rahbxd,rahbyd,0 'rahmen-rechts
'
glend
'
shading
color .90,.90,0
static float kublx,kubly 'kugel
static float vlx,vly 'beschl
static int tal,ntal 'score
if opening
vlx=0.2 'beschl
vly=0.1 'beschl
endif
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' either right paddle go or left paddle.. but not running both together ------- //
pushstate 'right paddle ok
move kublx,kubly
'go sphere 'radius 0.5
popstate
pushstate 'left paddle ok
move -kublx,kubly
'go sphere 'radius 0.5
go sphere
popstate
'---------------------------------------------------------------- //
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
kublx+=vlx
kubly+=vly
'
'LIMIT AND BOUNCE
' kugel 'bwlimit der kugel
if kublx > bxllim
vlx = -vlx
ntal++
elseif kublx<-bxllim
vlx = -vlx
endif
'
if kubly>byllim
vly = -vly
elseif kubly <-byllim
vly = -vly
endif
'
'PONG BAT AND SCORE
'
if opening
static float pobtu=2.0 '2.0
static float pobtx=bxllim-2.0 '2.0
static float pobty=0.0
endif
'pong impact
if kublx>=pobtx-1.0 '+1.0 '+geht nicht, wichtig wo pong aufschlägt
if vlx<0.0
'bouncing behind bat
elseif kubly>pobty+pobtu+0.5
'above bat
elseif kubly<pobty-pobtu-0.5
'below bat
else
tal++
vlx = -vlx
endif
endif
'pong2 impact
if kublx>=pobtx-1.0 '+1.0 '+geht nicht, wichtig wo pong aufschlägt
if vlx<0.0
'bouncing behind bat
elseif kubly>pobty+pobtu+0.5
'above bat
elseif kublx<pobtx-pobtu-0.5
'below bat
else
tal++
vlx = -vlx
endif
endif
'SCORE -------------------------- //
flat
pushstate
'move -rahbxd,rahbyd+1.0 'rahmen
scale 2
print str(tal)" / "+str(ntal)
popstate
'
'
'pong bat render rechts
pushstate
glbegin GL_QUADS
glvertex3f pobtx-0.25,pobty-pobtu,0
glvertex3f pobtx+0.25,pobty-pobtu,0
glvertex3f pobtx+0.25,pobty+pobtu,0
glvertex3f pobtx-0.25,pobty+pobtu,0
glend
popstate
'
'pong2 bat render geht :-) links
pushstate
'gltranslatef -24.0,0.0,0.0
glbegin GL_QUADS
glvertex3f -pobtx-0.25,pobty-pobtu,0
glvertex3f -pobtx+0.25,pobty-pobtu,0
glvertex3f -pobtx+0.25,pobty+pobtu,0
glvertex3f -pobtx-0.25,pobty+pobtu,0
glend
popstate
end if
'
'KEYBOARD CONTROL
if GetAsyncKeyState VK_UP
if rahbyd > pobty+pobtu 'limit
pobty+=0.1
endif
endif
if GetAsyncKeyState VK_DOWN
if -rahbyd < pobty-pobtu
pobty-=0.1
endif
endif
'
end sub
EndScript
How would you like to control each paddle? The left paddle could be controlled with keys 'W' up and 'Z' down.
Left Paddle is running with Pong2 Impact bat here Well now but Not right Side with Pong Impact bat See my Code :)
Have built your example Side twisted to understand Pong Impact bat Feature:)
I suggest the Pong Impact bat for both Paddle must be quite different
'
'PONG BAT AND SCORE
'
if opening
static float pobtu=2.0 '2.0
static float pobtx=bxllim-2.0 '2.0
static float pobty=0.0
endif
'------------------------------------------- //
'pong impact - right side dont work now
if kublx>=pobtx-1.0 '+1.0 '+geht nicht, wichtig wo pong aufschlägt
if vlx<0.0
'bouncing behind bat
elseif kubly>pobty+pobtu+0.5
'above bat
elseif kubly<pobty-pobtu-0.5
'below bat
else
tal++
vlx = -vlx
endif
endif
'pong2 impact here: left side is working well
if kublx>=pobtx-1.0 '
if vlx<0.0
'bouncing behind bat
elseif kubly>pobty+pobtu+0.5
'above bat
elseif kublx<pobtx-pobtu-0.5
'below bat
else
tal++
vlx = -vlx
endif
endif
'SCORE -------------------------- //
flat
pushstate
move -rahbxd,rahbyd+1.0 'rahmen
scale 2
print str(tal)" / "+str(ntal)
popstate
'
'
'pong bat render rechts doesn't work
pushstate
glbegin GL_QUADS
glvertex3f pobtx-0.25,pobty-pobtu,0
glvertex3f pobtx+0.25,pobty-pobtu,0
glvertex3f pobtx+0.25,pobty+pobtu,0
glvertex3f pobtx-0.25,pobty+pobtu,0
glend
popstate
'
'pong2 bat render left side is running well :-)
pushstate
'gltranslatef -24.0,0.0,0.0
glbegin GL_QUADS
glvertex3f -pobtx-0.25,pobty-pobtu,0
glvertex3f -pobtx+0.25,pobty-pobtu,0
glvertex3f -pobtx+0.25,pobty+pobtu,0
glvertex3f -pobtx-0.25,pobty+pobtu,0
glend
popstate
end if
'
'KEYBOARD CONTROL
if GetAsyncKeyState VK_UP
if rahbyd > pobty+pobtu 'limit
pobty+=0.1
endif
endif
if GetAsyncKeyState VK_DOWN
if -rahbyd < pobty-pobtu
pobty-=0.1
endif
endif
'
Yes, create completely independent bats with their own variables and mirror impact logic. You could even add extra bats, top and bottom :)
PongBase2.o2bas
static float btu1, btx1, bty1 'LEFT BAT
static float btu2, btx2, bty2 'RIGHT BAT
...
#compact
% filename "t.exe"
'uses RTL32
% Title "PONG BASE 2"
% Animated
% ScaleUp
% PlaceCentral
'% AnchorCentral
uses ConsoleG
indexbase 0
'sys sseed=GetTickCount
sub main()
==========
'
'static float ay
'static sys pki,count
glClearColor 0,0.20,0,0
if not pick
thickness 3
if opening
static float byl=10
static float bxl=15
static float byd=11
static float bxd=16
endif
'
flat
color 0,.40,0
float z=-0.0001
glbegin GL_QUADS
glvertex3f -bxd,-byd,z
glvertex3f bxd,-byd,z
glvertex3f bxd,byd,z
glvertex3f -bxd,byd,z
glend
'
color .99,.22,0
glbegin GL_LINES
glvertex3f -bxd,-byd,0
glvertex3f bxd,-byd,0
'
glvertex3f -bxd,byd,0
glvertex3f bxd,byd,0
'
glvertex3f -bxd,-byd,0
glvertex3f -bxd,byd,0
'
glvertex3f bxd,-byd,0
glvertex3f bxd,byd,0
'
glend
'
shading
color .90,.90,0
static float blx,bly
static float vlx,vly 'ball velocity
static int tal1,tal2 'scores
if opening
vlx=0.2
vly=0.1
endif
'
pushstate
move blx,bly
go sphere 'radius 0.5
popstate
blx+=vlx
bly+=vly
'
'LIMIT AND BOUNCE
'
if blx>bxl
vlx = -vlx
elseif blx< -bxl
vlx = -vlx
endif
'
if bly>byl
vly = -vly
elseif bly < -byl
vly = -vly
endif
'
'PONG BAT AND SCORE
'
static float btu1, btx1, bty1 'LEFT BAT
static float btu2, btx2, bty2 'RIGHT BAT
'
if opening
btu1=2.0
btx1=-bxl+2.0
bty1=0.0
btu2=2.0
btx2=bxl-2.0
bty2=0.0
endif
'
'PONG LEFT BAT
'
if blx<=btx1+1.0
if vlx>0.0
'bouncing behind bat1
elseif bly>bty1+btu1+0.5
'above bat
elseif bly<bty1-btu1-0.5
'below bat
else
tal1++
vlx = -vlx
endif
endif
'
'PONG RIGHT BAT
'
if blx>=btx2-1.0
if vlx<0.0
'bouncing behind bat
elseif bly>bty2+btu2+0.5
'above bat
elseif bly<bty2-btu2-0.5
'below bat
else
tal2++
vlx = -vlx
endif
endif
'
'SCORE
flat
pushstate
move -bxd,byd+1.0
scale 2.0
print str(tal1)
popstate
'
pushstate
move bxd-2.0,byd+1.0
scale 2
print str(tal2)
popstate
'
'
'pong bats render
pushstate
glbegin GL_QUADS
'left bat
glvertex3f btx1-0.25,bty1-btu1,0
glvertex3f btx1+0.25,bty1-btu1,0
glvertex3f btx1+0.25,bty1+btu1,0
glvertex3f btx1-0.25,bty1+btu1,0
'right bat
glvertex3f btx2-0.25,bty2-btu2,0
glvertex3f btx2+0.25,bty2-btu2,0
glvertex3f btx2+0.25,bty2+btu2,0
glvertex3f btx2-0.25,bty2+btu2,0
glend
popstate
'
end if
'
'KEYBOARD CONTROLS
'
'LEFT BAT
if GetAsyncKeyState 0x57 'Q' up
if byd>bty1+btu1 'limit
bty1+=0.1
endif
endif
if GetAsyncKeyState 0x5a 'Z' down
if -byd < bty1-btu1
bty1-=0.1
endif
endif
'
'RIGHT BAT
if GetAsyncKeyState VK_UP
if byd>bty2+btu2 'limit
bty2+=0.1
endif
endif
if GetAsyncKeyState VK_DOWN
if -byd < bty2-btu2
bty2-=0.1
endif
endif
'
end sub
EndScript
Many thanks Charles I have learned my Lessons :) translated to my example to understand and all is running Well super Bye Frank