One more question about General programming with consoleG
It's possible in moveable objects with Text to produce a collision without using the glVertex x,y,z with the Standard programming (Pong Game) and to use IT for example a GL_Quads AS one closed Block you can move and let make a collision?
'-- test openGL oxygen
'-- moveable text and objects part two, frank bruebach
'-- 24-25/02/2024
' Question: its possible to make a collision between object 500 and 400 both cubes
' without using the standard way of collision with glVertex3f x,y,z ?
' perhaps it's possible to use the GL_QUADS below as one new Object as a "block" ?
#compact
% Title "ConsoleG Demo: Move text and objects with mouse and arrow keys etc"
'% WindowStyle WS_OVERLAPPEDWINDOW
'% Animated
'% ScaleUp
% PlaceCentral
% AnchorCentral
% shaders
$filename "t.exe"
'uses RTL64
uses consoleG
'Keys: Esc, arrow-keys, n,m, F4
BeginScript
sub main
========
'WaitForEvent '0 off 1 on (default on)
static int z, y, x
static quad t1,t2,t3
if opening then 'FIRST CALL ONLY
timemark t1
picked=100
'mbox "helo"
end if
'
if closing then 'FINAL CALL BEFORE SHUTDOWN
'mbox "Bye!"
'exit sub
end if
cls
pushstate
color 1,.5,0,1
UserMovement m1,100 'identity in steps of 100
scale 2, 3
print "Hello "
popstate
move 5
pushstate
color 1,1,0,1
UserMovement m2,200
scale 4
print "World"
popstate
if not pick then
if key[49] then picked=100 'keypress '1'
if key[50] then picked=200 'kypress '2'
pushstate
move -20,12
static sys tally
timemark t2
scale 1.0
'
macro pr(a,b) 'PRINTING LIST
pushstate : color .5,1,1 : print a : popstate
pushstate : color 1,1,.5 : move 8 : print b : popstate
printl ""
end macro
'
'pr "Action Code: ", str(act)
pr "Picked ID: ", str(picked)
pr "Keyboard Code: ", str(keyd)
popstate
end if
cls 0.0, 0.2, 0.7
shading
scale 1 '3
move 1,-4
pushstate
Material Gold
UserMovement m3,300
static float ang
rotateX 'ang
rotateY 'ang
scale 1,3,4
go cube
popstate
'ang+=.5 : if ang>=360 then ang-=360
'--------------------------------- //
'
scale 2 '3
move -4,-2
pushstate
UserMovement m4,400
' -- Creates quads, shapes with 4 vertices
glbegin GL_QUADS
glcolor4f 1,0,0,1 ' 255 -- Red color
glvertex3f -1, -1, 0
glcolor4f 0, 1, 0,1 ' -- Green color
glvertex3f 1, -1, 0
glcolor4f 0, 0, 1,1 ' -- Blue color
glvertex3f 1, 1, 0
glcolor4f 1, 1, 0,1 ' -- Yellow color
glvertex3f -1, 1, 0
glend
popstate
'------------------ left little cube --------------- //
'
static single ang1,angi1=-2,angi2=1
static float ang,ang2
float s1,s2,s3,s4
's1=.2
's2=-1
's3=0.5
's4=s3*.2
s1=.4
s2=-2
s3=1.5
s4=s3*.4
scale 2.5
move -3,2
pushstate
Material Gold
UserMovement m5,500
' its possible to make a collision between object 500 and 400 both cubes
' without using the standard way of collision with glVertex3f x,y,z ?
' perhaps it's possible to use the GL_QUADS below as one new Object as a "block" ?
glbegin GL_QUADS
glcolor4f s3, 0, s4, 1
glvertex3f -s1, -s1, s2
glcolor4f 0, s3, s4, 1
glvertex3f -s1, s1, s2
glcolor4f s4, 0, s3, 1
glvertex3f s1, s1, s2
glcolor4f s3, 0, s4, 1
glvertex3f s1, -s1, s2
glend
popstate
sleep 15
end sub 'main
EndScript
I Hope you can follows my thoughts ;)
Hi Charles
It's Just an Idea how to improve or simplifier a collision for objects Made this fictive Code for consoleG (Same example Like above)
' fictive code example only an idea for boundingbox for a cube m500 and m400
'
' This example serves for a moving the cube in discrete steps (e.g., one unit at a time)
' Movement logic for cube 500
if key_up_pressed then
moveCube500(0, 1) ' Move up one unit at a time
elseif key_down_pressed then
moveCube500(0, -1) ' Move down
elseif key_left_pressed then
moveCube500(-1, 0) ' Move left
elseif key_right_pressed then
moveCube500(1, 0) ' Move right
end if
int new_x, newy
' Function to move cube 500 and handle collision
sub moveCube500(int dx, int dy)
' Calculate new position
new_x = cube500_x + dx
new_y = cube500_y + dy
' Check for collision with cube 400
collision = BoundingBoxIntersect(new_x, new_y, cube_width, cube_height, cube400_x, cube400_y, cube_width, cube_height)
' If no collision, update position
if not collision then
cube500_x = new_x
cube500_y = new_y
end if
end sub