They should all run even on Lachie's computer. ;-)
In all of the programs, the space bar toggles the camera mode.
1) Maze
This is a 3D maze with one level.
Controls: left, right, and up
This uses Inkey, so don't hold the keys down.
Code: Select all
' 3D Maze in OpenGL! v1.0
' (C) 2008 Innova and Kristopher Windsor
#include "GL/gl.bi"
#include "GL/glu.bi"
'undefine this to see 2D FBGFX display
#define d3
Const screenx = 640, screeny = 480
Const true = -1, false = 0, pihalf = Atn(1) * 2
Const map_max = 64
Type camera_type
As Double eye(1 To 3)
As Double see(1 To 3)
As Double up(1 To 3)
'transition
As Double teye(1 To 3)
As Double tsee(1 To 3)
As Double tup(1 To 3)
End Type
Type finish_type
As Integer x, y
End Type
Type map_type
As Integer c
As Integer ison
End Type
Type player_type
As Integer x, y
As Integer angle '0 - 3 (multiply by pi / 2)
'transition
As Double tx, ty
As Double tangle, tav '0 - 3.999...
End Type
Dim Shared As Integer map_total_x, map_total_y
Dim Shared LightDiffuse(0 To 3) As Single => {2, 2, 2, 1}
Dim Shared LightPosition(0 To 3) As Single => {0, 0, 0, 1}
Dim Shared As String key
Dim Shared As camera_type camera 'openGL mode only
Dim Shared As finish_type finish
Dim Shared As map_type map(1 To map_max, 1 To map_max)
Dim Shared As player_type player
Sub map_reset
Dim As String l
map_total_x = 0
map_total_y = 0
Restore
Do
Read l
If l <> "END" Then
map_total_y += 1
If map_total_y = 1 Then map_total_x = Len(l)
For a As Integer = 1 To map_total_x
With map(a, map_total_y)
.c = Rgb(Rnd * 256, Rnd * 256, Rnd * 256)
.ison = (Mid(l, a, 1) = "0")
If Mid(l, a, 1) = "X" Then
With finish
.x = a
.y = map_total_y
End With
End If
End With
Next a
End If
Loop Until l = "END"
End Sub
Sub player_reset
With player
.x = 2
.y = 2
.angle = 0
.tx = .x
.ty = .y
.tangle = .angle
.tav = 0
End With
End Sub
Sub player_move
Dim As Integer x, y
With player
'input
Select Case key
Case Chr(255, 75)
'left
.angle -= 1
If .angle = -1 Then .angle = 3
.tav = -.15
Case Chr(255, 77)
'right
.angle += 1
If .angle = 4 Then .angle = 0
.tav = .15
Case Chr(255, 72)
'advance
x = .x
y = .y
Select Case .angle
Case 0
x += 1
Case 1
y += 1
Case 2
x -= 1
Case 3
y -= 1
End Select
If map(x, y).ison = false Then
.x = x
.y = y
End If
End Select
'animation
.tx += (.x - .tx) / 10
.ty += (.y - .ty) / 10
If Abs(.angle - .tangle) < .15 Then
.tav = 0
Else
.tangle += .tav
If .tangle >= 4 Then .tangle -= 4
If .tangle < 0 Then .tangle += 4
End If
End With
End Sub
#ifdef d3
Sub display_start
Screenres screenx, screeny, 32,, 2
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 35.0, screenx / screeny, .1, 300
glMatrixMode GL_MODELVIEW
glLoadIdentity
glClearColor 0, 0, 0, 1
glEnable GL_DEPTH_TEST 'properly handles overlapping polygons (draw order for layering)
glEnable GL_LIGHT1
glLightfv GL_LIGHT1, GL_DIFFUSE, @LightDiffuse(0)
glEnable GL_LIGHTING
glEnable GL_COLOR_MATERIAL
End Sub
Sub display_go
Static As Integer camera_mode
Dim As Double r, g, b
Dim As Double cx, cy, pa
If key = " " Then camera_mode = Not camera_mode
'coords are set for bird's eye view
'top left of map is at (0, 0, 0)
'all parts of map are 1un cubed
glClear GL_DEPTH_BUFFER_BIT Or GL_COLOR_BUFFER_BIT
glLoadIdentity
With camera
If camera_mode Then
pa = player.tangle * pihalf
.eye(1) = player.tx + .5
.eye(2) = player.ty + .5
.eye(3) = -.5
.see(1) = player.tx + Cos(pa) + .5
.see(2) = player.ty + Sin(pa) + .5
.see(3) = -.5
.up(1) = 0
.up(2) = 0
.up(3) = -1 '-1 keeps y-coords like fbgfx (not like graphing coords)
Else
.eye(1) = map_total_x / 2
.eye(2) = map_total_y / 2
.eye(3) = -map_total_x * 1.4
.see(1) = map_total_x / 2
.see(2) = map_total_y / 2
.see(3) = 0
.up(1) = 0
.up(2) = -1 '-1 keeps y-coords like fbgfx (not like graphing coords)
.up(3) = 0
End If
LightPosition(0) = .eye(1) 'player.tx + .5'
LightPosition(1) = .eye(2) 'player.ty + .5'
LightPosition(2) = .eye(3) '-.5'
glLightfv GL_LIGHT1, GL_POSITION, @LightPosition(0)
For a As Integer = 1 To 3
.teye(a) += (.eye(a) - .teye(a)) / 8
.tsee(a) += (.see(a) - .tsee(a)) / 8
.tup(a) += (.up(a) - .tup(a)) / 8
Next a
gluLookat .teye(1), .teye(2), .teye(3), .tsee(1), .tsee(2), .tsee(3), .tup(1), .tup(2), .tup(3)
End With
'map
glBegin GL_QUADS
For x As Integer = 1 To map_total_x
For y As Integer = 1 To map_total_y
With map(x, y)
If .ison Then
r = ((.c And &HFF0000) Shr 16) / 255
g = ((.c And &HFF00) Shr 8) / 255
b = (.c And &HFF) / 255
'ceiling
glColor3f r, g, b
glNormal3f 0, 0, 1
glVertex3f x, y, -1
glVertex3f x + 1, y, -1
glVertex3f x + 1, y + 1, -1
glVertex3f x, y + 1, -1
'left wall
glColor3f r, g, b
glNormal3f -1, 0, 0
glVertex3f x, y, 0
glVertex3f x, y + 1, 0
glVertex3f x, y + 1, -1
glVertex3f x, y, -1
'right wall
glColor3f r, g, b
glNormal3f 1, 0, 0
glVertex3f x + 1, y, 0
glVertex3f x + 1, y + 1, 0
glVertex3f x + 1, y + 1, -1
glVertex3f x + 1, y, -1
'north wall
glColor3f r, g, b
glNormal3f 0, -1, 0
glVertex3f x, y, 0
glVertex3f x + 1, y, 0
glVertex3f x + 1, y, -1
glVertex3f x, y, -1
'south wall
glColor3f r, g, b
glNormal3f 0, 1, 0
glVertex3f x, y + 1, 0
glVertex3f x + 1, y + 1, 0
glVertex3f x + 1, y + 1, -1
glVertex3f x, y + 1, -1
End If
End With
Next y
Next x
glEnd
'finish
glBegin GL_TRIANGLES
With finish
'left
glColor3f 1, 1, 1
glNormal3f -1, 0, 0
glVertex3f .x + .5, .y + .5, -1
glVertex3f .x, .y, 0
glVertex3f .x, .y + 1, 0
'right
glColor3f 1, 1, 1
glNormal3f 1, 0, 0
glVertex3f .x + .5, .y + .5, -1
glVertex3f .x + 1, .y, 0
glVertex3f .x + 1, .y + 1, 0
'top
glColor3f 1, 1, 1
glNormal3f 0, -1, 0
glVertex3f .x + .5, .y + .5, -1
glVertex3f .x, .y, 0
glVertex3f .x + 1, .y, 0
'bottom
glColor3f 1, 1, 1
glNormal3f 0, 1, 0
glVertex3f .x + .5, .y + .5, -1
glVertex3f .x, .y + 1, 0
glVertex3f .x + 1, .y + 1, 0
End With
glEnd
'player
glBegin GL_QUADS
With player
cx = .tx + .5
cy = .ty + .5
pa = .tangle * pihalf
glColor3f 1, 1, 1
glNormal3f 0, 0, -1
glVertex3f cx - Cos(pa) * .2, cy - Sin(pa) * .2, -.2
glVertex3f cx + Cos(pa + pihalf) * .5, cy + Sin(pa + pihalf) * .5, -.2
glVertex3f cx + Cos(pa) * .6, cy + Sin(pa) * .6, -.2
glVertex3f cx + Cos(pa - pihalf) * .5, cy + Sin(pa - pihalf) * .5, -.2
End With
glEnd
Flip
End Sub
#else
Sub display_start
Screenres screenx, screeny, 32
End Sub
Sub display_go
Screenlock
Cls
'map
For x As Integer = 1 To map_total_x
For y As Integer = 1 To map_total_y
With map(x, y)
If .ison Then
Line (x * 12, y * 12) - Step(11, 11), .c, BF
End If
End With
Next y
Next x
'finish
With finish
Line (.x * 12 + 2, .y * 12 + 2) - Step(7, 7), &HFFFFFFFF, BF
End With
'player
With player
Circle (.tx * 12 + 6, .ty * 12 + 6), 6, &HFFFFFFFF,,, 1
Line Step(0, 0) - Step(Cos(.tangle * pihalf) * 6, Sin(.tangle * pihalf) * 6), &HFFFFFFFF
End With
Screenunlock
End Sub
#endif
Sub game_play
map_reset
player_reset
Do
player_move
display_go
Sleep 10
key = Inkey
Loop Until key = Chr(27) Or (player.x = finish.x And player.y = finish.y)
End Sub
display_start
game_play
Data "00000000000000000000000000000"
Data "0 0 0 0 0 0"
Data "0 0 0 0 0000000 0 0000"
Data "0 0 0 00 0 0"
Data "0 0 0 00 0000000000000 0"
Data "0 0 0 00 0 0 0"
Data "0 0 00 0 000000 0 000"
Data "000000000 00 0 0 0 0"
Data "0 0 0 000000 000 0"
Data "000000000 0 00 0 0 0"
Data "0 0 00 0 000000 000"
Data "0 000000000 00 0 0 0 0"
Data "0 00 X0 0 0 0"
Data "00000000000000000000000000000"
Data "END"
This is a ride around the city demo.
Of course, since you're on the train, you can't see the train. :-P
This program has no controls, except the space bar.
Code: Select all
' Ride the Train Walkaround OpenGL Demo! v1.0
' (C) 2008 Innova and Kristopher Windsor
#include "GL/gl.bi"
#include "GL/glu.bi"
Const screenx = 640, screeny = 480
Const mapx = 10, mapy = 10
Const true = -1, false = 0, pihalf = Atn(1) * 2
Const building_max = 12, road_max = 48, tree_max = 40
Type camera_type
As Double eye(1 To 3)
As Double see(1 To 3)
As Double up(1 To 3)
End Type
Type coord_type
As Double x, y
End Type
Type train_type
As Integer road_current
As Double angle
As coord_type p
End Type
Dim Shared LightDiffuse(0 To 3) As Single => {2, 2, 2, 1}
Dim Shared LightPosition(0 To 3) As Single => {0, 0, 0, 1}
Dim Shared As String key
Dim Shared As camera_type camera
Dim Shared As coord_type building(1 To building_max)
Dim Shared As coord_type road(1 To road_max)
Dim Shared As coord_type tree(1 To tree_max)
Dim Shared As train_type train
Sub start
Dim As Integer can
Dim As Double x, y, xv, yv
Screenres screenx, screeny, 32,, 2
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 35.0, screenx / screeny, .1, 20
glMatrixMode GL_MODELVIEW
glLoadIdentity
glClearColor 0, 0, 0, 1
glEnable GL_DEPTH_TEST 'properly handles overlapping polygons (draw order for layering)
glEnable GL_LIGHT1
glLightfv GL_LIGHT1, GL_DIFFUSE, @LightDiffuse(0)
glEnable GL_LIGHTING
glEnable GL_COLOR_MATERIAL
Randomize Timer
x = 2: y = 2
xv = .5
For a As Integer = 1 To road_max
Select Case a - 1
Case 12
Swap xv, yv
Case 18
Swap xv, yv
xv *= -1
Case 24
Swap xv, yv
yv *= -1
Case 30
Swap xv, yv
xv *= -1
Case 36
Swap xv, yv
End Select
x += xv
y += yv
With road(a)
.x = x
.y = y
End With
Next a
For a As Integer = 1 To building_max
With building(a)
Do
.x = Rnd * mapx
.y = Rnd * mapy
can = true
For b As Integer = 1 To road_max
If Abs(.x - road(b).x) + Abs(.y - road(b).y) < 1 Then can = false
Next b
Loop Until can
End With
Next a
For a As Integer = 1 To tree_max
With tree(a)
Do
.x = Rnd * mapx
.y = Rnd * mapy
can = true
For b As Integer = 1 To road_max
If Abs(.x - road(b).x) + Abs(.y - road(b).y) < 1 Then can = false
Next b
For b As Integer = 1 To building_max
If Abs(.x - building(b).x) + Abs(.y - building(b).y) < 1 Then can = false
Next b
Loop Until can
End With
Next a
With train
.road_current = 2
.p.x = road(1).x
.p.y = road(1).y
End With
End Sub
Sub go
Dim As Double a
'coords are set for bird's eye view
'top left of map is at (0, 0, 0)
'all parts of map are 1un cubed
glClear GL_DEPTH_BUFFER_BIT Or GL_COLOR_BUFFER_BIT
glLoadIdentity
Static As Double xx
With train
a = Atan2(road(.road_current).y - .p.y, road(.road_current).x - .p.x)
If Abs(a - .angle) > .02 Then
.angle += Sgn(a - .angle) * .02
Else
.angle = a
.p.x += Cos(a) * .05
.p.y += Sin(a) * .05
If Abs(.p.y - road(.road_current).y) + Abs(.p.x - road(.road_current).x) < .1 Then
.p.y = road(.road_current).y
.p.x = road(.road_current).x
.road_current += 1
If .road_current = road_max Then .road_current = 1
End If
End If
LightPosition(0) = .p.x
LightPosition(1) = .p.y
LightPosition(2) = -1
glLightfv GL_LIGHT1, GL_POSITION, @LightPosition(0)
End With
With camera
If Multikey(&H39) Then
.eye(1) = mapx / 2
.eye(2) = mapy / 2
.eye(3) = -mapx * 1.4
.see(1) = mapx / 2
.see(2) = mapy / 2
.see(3) = 0
.up(1) = 0
.up(2) = 1
.up(3) = 0
Else
.eye(1) = train.p.x
.eye(2) = train.p.y
.eye(3) = -.2
.see(1) = train.p.x + Cos(train.angle)
.see(2) = train.p.y + Sin(train.angle)
.see(3) = -.2
.up(1) = 0
.up(2) = 0
.up(3) = -1
End If
gluLookat .eye(1), .eye(2), .eye(3), .see(1), .see(2), .see(3), .up(1), .up(2), .up(3)
End With
glBegin GL_QUADS
'ground
glColor3d .4, .2, 0
glNormal3f 0, 0, -1
glVertex3d 0, 0, 0
glVertex3d mapx, 0, 0
glVertex3d mapx, mapy, 0
glVertex3d 0, mapy, 0
'road
For a As Integer = 1 To road_max
With road(a)
glColor3d 1, .6, .2
glNormal3f 0, 0, -1
glVertex3d .x - .25, .y - .25, -.04
glVertex3d .x + .25, .y - .25, -.04
glVertex3d .x + .25, .y + .25, -.04
glVertex3d .x - .25, .y + .25, -.04
End With
Next a
'buildings
For a As Integer = 1 To building_max
With building(a)
'left
glColor3d .6, .6, .8
glNormal3f -1, 0, 0
glVertex3d .x - .5, .y - .5, 0
glVertex3d .x - .5, .y + .5, 0
glVertex3d .x - .5, .y + .5, -1
glVertex3d .x - .5, .y - .5, -1
'right
glColor3d .6, .6, .8
glNormal3f 1, 0, 0
glVertex3d .x + .5, .y - .5, 0
glVertex3d .x + .5, .y + .5, 0
glVertex3d .x + .5, .y + .5, -1
glVertex3d .x + .5, .y - .5, -1
'north
glColor3d .6, .6, .8
glNormal3f 0, 1, 0
glVertex3d .x - .5, .y + .5, 0
glVertex3d .x + .5, .y + .5, 0
glVertex3d .x + .5, .y + .5, -1
glVertex3d .x - .5, .y + .5, -1
'south
glColor3d .6, .6, .8
glNormal3f 0, -1, 0
glVertex3d .x - .5, .y - .5, 0
glVertex3d .x + .5, .y - .5, 0
glVertex3d .x + .5, .y - .5, -1
glVertex3d .x - .5, .y - .5, -1
'roof
glColor3d .6, .6, .8
glNormal3f 0, 0, -1
glVertex3d .x - .5, .y - .5, -1
glVertex3d .x + .5, .y - .5, -1
glVertex3d .x + .5, .y + .5, -1
glVertex3d .x - .5, .y + .5, -1
End With
Next a
glEnd
glBegin GL_TRIANGLES
'trees
For a As Integer = 1 To tree_max
With tree(a)
glColor3d .2, 1, .2
glNormal3f -1, 0, 0
glVertex3d .x, .y, -.5
glVertex3d .x - .1, .y - .1, 0
glVertex3d .x - .1, .y + .1, 0
glColor3d .2, 1, .2
glNormal3f 1, 0, 0
glVertex3d .x, .y, -.5
glVertex3d .x + .1, .y - .1, 0
glVertex3d .x + .1, .y + .1, 0
glColor3d .2, 1, .2
glNormal3f 0, -1, 0
glVertex3d .x, .y, -.5
glVertex3d .x - .1, .y - .1, 0
glVertex3d .x + .1, .y - .1, 0
glColor3d .2, 1, .2
glNormal3f 0, 1, 0
glVertex3d .x, .y, -.5
glVertex3d .x - .1, .y + .1, 0
glVertex3d .x + .1, .y + .1, 0
End With
Next a
'train
With train
glColor3d 1, 1, 1
glNormal3f 0, 0, -1
glVertex3d .p.x, .p.y, -.2
glVertex3d .p.x + Cos(.angle + .1), .p.y + Sin(.angle + .1), -.2
glVertex3d .p.x + Cos(.angle - .1), .p.y + Sin(.angle - .1), -.2
End With
glEnd
Flip
End Sub
Sub main
start
Do
go
Sleep 10
key = Inkey
Loop Until key = Chr(27)
End Sub
main
This is another demo without controls (except the space bar).
The space ships were inspired by Star Wars, although they only have 3 polygons. xD
Code: Select all
' Watch the Space Wars OpenGL Demo! v1.0
' (C) 2008 Innova and Kristopher Windsor
#include "GL/gl.bi"
#include "GL/glu.bi"
Const screenx = 640, screeny = 480
Const true = -1, false = 0, pi = Atn(1) * 4
Const missile_max = 256, pod_max = 8
Type camera_type
As Double eye(1 To 3)
As Double see(1 To 3)
As Double up(1 To 3)
End Type
Type coord_type
As Double x, y
End Type
Type missile_type
As coord_type p, v
As Integer killme
End Type
Dim Shared As Integer missile_total
Dim Shared LightDiffuse(0 To 3) As Single => {3, 3, 3, 1}
Dim Shared LightPosition(0 To 3) As Single => {0, 0, 0, 1}
Dim Shared As Double pod(1 To pod_max)
Dim Shared As String key
Dim Shared As camera_type camera
Dim Shared As missile_type missile(1 To missile_max)
Sub start
Screenres screenx, screeny, 32,, 2
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 35.0, screenx / screeny, .05, 8
glMatrixMode GL_MODELVIEW
glLoadIdentity
glClearColor 0, 0, 0, 1
glEnable GL_DEPTH_TEST 'properly handles overlapping polygons (draw order for layering)
glEnable GL_LIGHT1
glLightfv GL_LIGHT1, GL_DIFFUSE, @LightDiffuse(0)
glEnable GL_LIGHTING
glEnable GL_COLOR_MATERIAL
Randomize Timer
For a As Integer = 1 To pod_max
pod(a) = Rnd * pi * 2
Next a
End Sub
Sub go
Dim As Integer i
Dim As Double d, cx, cy
'coords are set for bird's eye view
'top left of map is at (0, 0, 0)
'all parts of map are 1un cubed
'process space ships
For a As Integer = 1 To pod_max
pod(a) += .01
If Rnd < .1 Then
If missile_total + 2 <= missile_max Then
cx = Cos(pod(a))
cy = Sin(pod(a))
d = pod(a) + pi / 2
missile_total += 1
With missile(missile_total)
.p.x = cx + Cos(d + 1 * pi / 4) * .02
.p.y = cy + Sin(d + 1 * pi / 4) * .02
.v.x = Cos(d) * .1
.v.y = Sin(d) * .1
.killme = false
End With
missile_total += 1
With missile(missile_total)
.p.x = cx + Cos(d + 5 * pi / 4) * .02
.p.y = cy + Sin(d + 5 * pi / 4) * .02
.v.x = Cos(d) * .1
.v.y = Sin(d) * .1
.killme = false
End With
End If
End If
Next a
'process missiles
For a As Integer = 1 To missile_total
With missile(a)
.p.x += .v.x
.p.y += .v.y
If .p.x < -5 Or .p.y < -5 Or .p.x > 5 Or .p.y > 5 Then .killme = true
End With
Next a
i = 1
While i <= missile_total
If missile(i).killme Then
Swap missile(i), missile(missile_total)
missile_total -= 1
Else
i += 1
End If
Wend
'start drawing
glClear GL_DEPTH_BUFFER_BIT Or GL_COLOR_BUFFER_BIT
glLoadIdentity
LightPosition(0) = 0
LightPosition(1) = 0
LightPosition(2) = 3
glLightfv GL_LIGHT1, GL_POSITION, @LightPosition(0)
With camera
If Multikey(&H39) Then
.eye(1) = 0
.eye(2) = 0
.eye(3) = 4
.see(1) = 0
.see(2) = 0
.see(3) = 0
.up(1) = 0
.up(2) = 1
.up(3) = 0
Else
d = Timer * .6
.eye(1) = Cos(d) + 1 '+ 1 centers on corner of blue ground
.eye(2) = Sin(d) + 1
.eye(3) = .5
.see(1) = 1
.see(2) = 1
.see(3) = .4 + Sin(d * .4) * .25
.up(1) = 0
.up(2) = 0
.up(3) = 1
End If
gluLookat .eye(1), .eye(2), .eye(3), .see(1), .see(2), .see(3), .up(1), .up(2), .up(3)
End With
glBegin GL_QUADS
'ground (blue)
glColor3d .2, .2, .8
glNormal3f 0, 0, 1
glVertex3d -1, -1, 0
glVertex3d 1, -1, 0
glVertex3d 1, 1, 0
glVertex3d -1, 1, 0
'extended ground (green)
glColor3d .2, .8, .2
glNormal3f 0, 0, 1
glVertex3d -2, -2, -.3
glVertex3d 2, -2, -.3
glVertex3d 2, 2, -.3
glVertex3d -2, 2, -.3
For a As Integer = 1 To pod_max
cx = Cos(pod(a))
cy = Sin(pod(a))
d = pod(a) + pi / 2
glColor3d 1, 1, 1
glNormal3f 0, 0, 1
glVertex3d cx + Cos(d + 1 * pi / 4) * .02, cy + Sin(d + 1 * pi / 4) * .02, .3
glVertex3d cx + Cos(d + 3 * pi / 4) * .02, cy + Sin(d + 3 * pi / 4) * .02, .3
glVertex3d cx + Cos(d + 5 * pi / 4) * .02, cy + Sin(d + 5 * pi / 4) * .02, .3
glVertex3d cx + Cos(d + 7 * pi / 4) * .02, cy + Sin(d + 7 * pi / 4) * .02, .3
glColor3d 1, 1, 1
glNormal3f Cos(d + pi / 2), Sin(d + pi / 2), 0
glVertex3d cx + Cos(d + 1 * pi / 4) * .02, cy + Sin(d + 1 * pi / 4) * .02, .25
glVertex3d cx + Cos(d + 1 * pi / 4) * .02, cy + Sin(d + 1 * pi / 4) * .02, .35
glVertex3d cx + Cos(d + 3 * pi / 4) * .02, cy + Sin(d + 3 * pi / 4) * .02, .35
glVertex3d cx + Cos(d + 3 * pi / 4) * .02, cy + Sin(d + 3 * pi / 4) * .02, .25
glColor3d 1, 1, 1
glNormal3f Cos(d + 3 * pi / 2), Sin(d + 3 * pi / 2), 0
glVertex3d cx + Cos(d + 5 * pi / 4) * .02, cy + Sin(d + 5 * pi / 4) * .02, .25
glVertex3d cx + Cos(d + 5 * pi / 4) * .02, cy + Sin(d + 5 * pi / 4) * .02, .35
glVertex3d cx + Cos(d + 7 * pi / 4) * .02, cy + Sin(d + 7 * pi / 4) * .02, .35
glVertex3d cx + Cos(d + 7 * pi / 4) * .02, cy + Sin(d + 7 * pi / 4) * .02, .25
Next a
For a As Integer = 1 To missile_total
With missile(a)
glColor3d 1, .2, .2
glNormal3f 0, 0, 1 'would take some rotation to be correct
glVertex3d .p.x, .p.y, .303
glVertex3d .p.x - .v.x / 2, .p.y - .v.y / 2, .303
glVertex3d .p.x - .v.x / 2, .p.y - .v.y / 2, .297
glVertex3d .p.x, .p.y, .297
End With
Next a
glEnd
Flip
End Sub
Sub main
start
Do
go
Sleep 20
key = Inkey
Loop Until key = Chr(27)
End Sub
main