Quote: "@Daemon:
The AI cars just rotate on the spot, collide with the one next to them, and just sit in a row of three on the starting grid. Is the AI not complete or is this not supposed to happen?"
That is not what happens on my computer!!! Here is the code I'm running (All I've added is that it sets display mode).
`The Usual Setup
sync on
sync rate 30
autocam off
hide mouse
randomize timer()
if check display mode(1024,768,32)=1
set display mode 1024,768,32
endif
set text font "Gungsuh"
`Variables
sw=screen width()
sh=screen height()
type car_info
acc as float
wpt as integer
lap as integer
finish as boolean
endtype
dim car(8) as car_info
type way_point
x as integer
z as integer
endtype
dim way(20) as way_point
null=make vector2(1)
null=make vector2(2)
dim pt(8) as string
pt(1)="st"
pt(2)="nd"
pt(3)="rd"
for i=4 to 8
pt(i)="th"
next i
place=8
dim comment(8) as string
comment(1)="Congradulations, you are God"
comment(2)="Ok, now you'll have to play again"
comment(3)="You still get a medal"
comment(4)="Do better"
comment(5)="Now your not even in the top 50%"
comment(6)="Shame"
comment(7)="You could have done worse"
comment(8)="Seek help"
`Stolen from Hobgoblin Lord
type note_thing
note as integer
speed as integer
volume as integer
endtype
dim master_note(-1) as note_thing
make_midi("R",25,2,"a4 a4 a4 g5")
load music "r.mid",1
`Grass
make_image_memblock(1,32,32,32)
for x=1 to 32
for y=1 to 32
memblock_dot(1,x,y,rgb(rnd(128),rnd(128)+127,0))
next y
next x
make image from memblock 10,1
`Road
for x=1 to 32
for y=1 to 32
c=rnd(20)+127
memblock_dot(1,x,y,rgb(c,c,c))
next y
next x
make image from memblock 11,1
`Wall
for x=1 to 32
for y=1 to 32
c=rnd(60)
memblock_dot(1,x,y,rgb(c,c,c))
next y
next x
make image from memblock 12,1
`Boost
for x=1 to 32
for y=1 to 32
memblock_dot(1,x,y,rgb(255,x*50 mod 256,0))
next y
next x
make image from memblock 15,1
delete memblock 1
set text size 14
color backdrop rgb(29, 94, 99)
`Choose Track
track=1
repeat
if escapekey()=1
end
endif
sync
set cursor 0,0
print "Select a track"
print ""
dim trackname(3) as string
trackname(1)="Winding Willow"
trackname(2)="Spring Track"
trackname(3)="Checker Field"
sprite 1,-10,-10,10
size sprite 1,10,10
for i=1 to 3
if i=track
ink rgb(123, 123, 238),0
arrow$=" <--------"
else
ink -1,0
arrow$=""
endif
print trackname(i)+arrow$
next i
select track
case 1
restore track1
endcase
case 2
restore track2
endcase
case 3
restore track3
endcase
endselect
for x=1 to 30
for z=1 to 30
read road
select road
case 0
set sprite image 1,10
endcase
case 1
set sprite image 1,11
endcase
case 2
set sprite image 1,12
endcase
case 3
set sprite image 1,15
endcase
endselect
paste sprite 1,x*10+200,400-z*10
next z
next x
track=track-upkey()+downkey()
if track<1
track=1
endif
if track>3
track=3
endif
ink -1,0
until returnkey()=1
delete sprite 1
`Make Car
set camera range 10,10000
color backdrop rgb(0, 210, 255)
make object box 1,50,30,100
make object box 2,10,10,15
make mesh from object 1,2
delete object 2
add limb 1,1,1
offset limb 1,1,0,20,-40
delete mesh 1
make object box 2,60,6,20
make mesh from object 1,2
delete object 2
add limb 1,2,1
offset limb 1,2,0,23,-40
delete mesh 1
make object sphere 2,100,6,6
scale object 2,6,25,25
make mesh from object 1,2
delete object 2
add limb 1,3,1
offset limb 1,3,28,-10,30
add limb 1,4,1
offset limb 1,4,-28,-10,30
add limb 1,5,1
offset limb 1,5,28,-10,-30
add limb 1,6,1
offset limb 1,6,-28,-10,-30
delete mesh 1
scale object 1,50,50,50
`Car colors
make_image_memblock(1,1,1,32)
for image=1 to 8
memblock_dot(1,1,1,rgb(rnd(255),rnd(255),rnd(255)))
make image from memblock image,1
next image
`Black Tire
memblock_dot(1,1,1,rgb(0,0,0))
make image from memblock 9,1
delete memblock 1
`Speedometer
make_image_memblock(1,256,128,32)
for thickness=0 to 2
memblock_circle(1,128,128+thickness,128,rgb(255,255,255))
next thickness
for ang=-90 to 90 step 10
memblock_line(1,int((cos(ang)-sin(ang)*30+129)),int((sin(ang)-cos(ang)*30+129)),int((cos(ang)-sin(ang)*120+129)),int((sin(ang)-cos(ang)*120+129)),rgb(255,255,255))
next ang
make image from memblock 13,1
delete memblock 1
sprite 1,sw-256,sh-152,13
hide sprite 1
`Speedometer needle
make_image_memblock(1,10,120,32)
memblock_circle(1,5,115,5,rgb(255,0,0))
for thickness=-2 to 2
memblock_line(1,5+thickness,110,5+thickness,1,rgb(255,0,0))
next thickness
make image from memblock 14,1
delete memblock 1
sprite 2,sw-130,sh-24,14
offset sprite 2,0,115
hide sprite 2
`Make enemies
for car=2 to 8
clone object car,1
next car
for car=1 to 8
texture object car,car
for i=3 to 6
texture limb car,i,9
next i
position object car,cos(car*180)*40+3700,0,car*40+2100
next car
`Make track
obj=9
dim track(30,30)
select track
case 1
restore track1
endcase
case 2
restore track2
endcase
case 3
restore track3
endcase
endselect
for x=1 to 30
for z=1 to 30
read road
track(x,z)=road
if road<2
make object plain obj,200,200,1
xrotate object obj,90
position object obj,x*200,-20,z*200
texture object obj,10+road
else
if road=2
make object box obj,200,50,200
position object obj,x*200,5,z*200
texture object obj,12
else
make object plain obj,200,200,1
xrotate object obj,90
position object obj,x*200,-20,z*200
texture object obj,15
endif
endif
inc obj
next z
next x
`Set waypoints for ai and keeping track of place
select track
case 1
way(0).x=19
way(0).z=13
way(1).x=20
way(1).z=16
way(2).x=26
way(2).z=18
way(3).x=29
way(3).z=22
way(4).x=23
way(4).z=27
way(5).x=15
way(5).z=26
way(6).x=13
way(6).z=17
way(7).x=11
way(7).z=16
way(8).x=8
way(8).z=19
way(9).x=8
way(9).z=25
way(10).x=4
way(10).z=24
way(11).x=4
way(11).z=15
way(12).x=7
way(12).z=11
way(13).x=8
way(13).z=4
way(14).x=17
way(14).z=4
way(15).x=20
way(15).z=3
way(16).x=21
way(16).z=7
way(17).x=18
way(17).z=10
numways=17
endcase
case 2
way(0).x=19
way(0).z=15
way(1).x=23
way(1).z=16
way(2).x=25
way(2).z=6
way(3).x=23
way(3).z=3
way(4).x=10
way(4).z=3
way(5).x=6
way(5).z=10
way(6).x=3
way(6).z=13
way(7).x=5
way(7).z=18
way(8).x=4
way(8).z=23
way(9).x=6
way(9).z=26
way(10).x=11
way(10).z=25
way(11).x=15
way(11).z=28
way(12).x=26
way(12).z=27
way(13).x=27
way(13).z=22
way(14).x=17
way(14).z=21
way(15).x=14
way(15).z=10
way(16).x=18
way(16).z=9
numways=16
endcase
case 3
way(0).x=17
way(0).z=15
way(1).x=12
way(1).z=15
way(2).x=12
way(2).z=6
way(3).x=4
way(3).z=5
way(4).x=4
way(4).z=10
way(5).x=6
way(5).z=12
way(6).x=3
way(6).z=16
way(7).x=6
way(7).z=26
way(8).x=12
way(8).z=23
way(9).x=15
way(9).z=24
way(10).x=20
way(10).z=23
way(11).x=26
way(11).z=22
way(12).x=26
way(12).z=13
way(13).x=24
way(13).z=5
way(14).x=21
way(14).z=5
numways=14
endcase
endselect
`Smooth glide to show off
set text size 100
position camera 0,5000,0
point camera 3000,0,3000
for i=1 to 400
sync
txt$="Get Ready! "
if i=310
play music 1
endif
if i>=310
txt$=txt$+str$((400-i)/30+1)
endif
ink rgb(0, 0, 160),0
center text screen width()/2-5,screen height()/2-55,txt$
ink -1,0
center text screen width()/2,screen height()/2-50,txt$
position camera curvevalue(object position x(1),camera position x(),80),curvevalue(1000,camera position y(),80),curvevalue(object position z(1),camera position z(),80)
rotate camera curveangle(90,camera angle x(),80),curveangle(0,camera angle y(),80),curveangle(0,camera angle z(),80)
next i
`Final bit of setup
rotate camera 90,0,0
set text size 24
show sprite 1
show sprite 2
`Main Loop
repeat
if escapekey()=1
end
endif
sync
`Display HUD
text 0,0,"Lap: "+str$(car(1).lap+1)
text 0,30,"Place: "+str$(place)+pt(place)
speed$=str$(int(abs(car(1).acc*3)))+" mph"
text sw-text width(speed$),sh-24,speed$
rotate sprite 2,abs(car(1).acc*3)-90
`Control player
oldx#=object position x(1)
oldz#=object position z(1)
`text 0,60,"X: "+str$(int(oldx#/200+0.5))+" Z: "+str$(int(oldz#/200+0.5))
road=track(int(oldx#/200+0.5),int(oldz#/200+0.5))
select road
case 0
friction#=.95
endcase
case 1
friction#=.98
endcase
case 3
friction#=1.2
endcase
endselect
car(1).acc=car(1).acc*friction#+(((upkey()+keystate(17))>0)-((downkey()+keystate(31))>0)*.4)*.7
move object 1,car(1).acc
turn=((rightkey()+keystate(32))>0)-((leftkey()+keystate(30))>0)
yrotate object 1,object angle y(1)+turn*4
rotate limb 1,3,0,turn*10,0
rotate limb 1,4,0,turn*10,0
rotate limb 1,5,0,-turn*10,0
rotate limb 1,6,0,-turn*10,0
newx#=object position x(1)
newz#=object position z(1)
colwith=object collision(1,0)
if colwith>0
position object 1,oldx#+(newx#-object position x(colwith))*.01,0,oldz#+(newz#-object position z(colwith))*.01
car(1).acc=car(1).acc*.1
endif
wx=way(car(1).wpt).x*200
wz=way(car(1).wpt).z*200
set vector2 1,object position x(1),object position z(1)
set vector2 2,wx,wz
subtract vector2 2,1,2
dist#=length vector2(2)
if dist#<1000
car(1).wpt=car(1).wpt+1
if car(1).wpt>numways
car(1).wpt=0
car(1).lap=car(1).lap+1
endif
endif
position camera object position x(1),1000,object position z(1)
tx=int(object position x(1)/200+0.5)
tz=int(object position z(1)/200+0.5)
if car(1).lap=5 and tx>16 and tx<22 and tz=13
car(1).finish=1
endif
`Control ai
for ai=2 to 8
ca#=object angle y(ai)
wx=way(car(ai).wpt).x*200
wz=way(car(ai).wpt).z*200
point object ai,wx,0,wz
na#=object angle y(ai)
rotate object ai,0,curveangle(na#,ca#,10),0
road=track(int(object position x(ai)/200+0.5),int(object position z(ai)/200+0.5))
select road
case 0
friction#=.95
endcase
case 1
friction#=.98
endcase
case 3
friction#=1.2
endcase
endselect
car(ai).acc=car(ai).acc*friction#+rnd(100)/100.0+.1
oldx#=object position x(ai)
oldz#=object position z(ai)
move object ai,car(ai).acc
newx#=object position x(ai)
newz#=object position z(ai)
colwith=object collision(ai,0)
if colwith>0
position object ai,oldx#+(newx#-object position x(colwith))*.01,0,oldz#+(newz#-object position z(colwith))*.01
car(ai).acc=car(ai).acc*.1
endif
set vector2 1,object position x(ai),object position z(ai)
set vector2 2,wx,wz
subtract vector2 2,1,2
dist#=length vector2(2)
if dist#<150
car(ai).wpt=car(ai).wpt+1
if car(ai).wpt>numways
car(ai).wpt=0
car(ai).lap=car(ai).lap+1
endif
endif
tx=int(object position x(ai)/200+0.5)
tz=int(object position z(ai)/200+0.5)
if car(ai).lap=5 and tx>16 and tx<22 and tz=13
car(ai).finish=1
endif
next ai
place=1
for i=2 to 8
if car(i).lap>car(1).lap or car(i).lap=car(1).lap and car(i).wpt=>car(1).wpt
inc place
endif
next i
until car(1).finish=1
`Display final info
delete objects 1,obj-1
delete sprite 1
delete sprite 2
color backdrop 0
set text size 50
cls
place=1
for i=2 to 8
if car(i).finish=1
inc place
endif
next i
center text screen width()/2,screen height()/2-25,"You ranked "+str$(place)+pt(place)
set text size 30
center text screen width()/2,screen height()/2+15,comment(place)
sync
wait key
end
track1:
data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,3,1,1,0,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,2
data 2,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,2,2,2,2,2,2,2,0,1,1,0,0,0,2
data 2,0,0,1,1,1,1,1,1,1,1,1,0,0,0,2,2,0,0,0,0,0,0,0,1,1,0,0,0,2
data 2,0,1,1,1,0,0,0,0,0,0,0,0,2,2,2,0,1,1,1,1,1,1,1,1,1,0,0,0,2
data 2,0,1,1,1,0,0,0,0,2,2,2,2,2,2,0,1,1,0,0,1,1,1,1,1,0,0,0,0,2
data 2,0,1,1,0,0,0,0,2,2,2,0,0,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2,2,0,1,1,0,0,2,0,2,0,0,1,0,0,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,2,0,2,0,0,0,1,0,0,0,0,0,2
data 2,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,2,0,2,0,2,0,0,1,0,0,0,0,0,2
data 2,0,0,0,0,1,1,1,1,1,1,1,1,1,0,2,0,2,0,2,0,0,1,1,0,0,0,0,0,2
data 2,0,0,0,1,1,1,1,0,0,2,0,2,0,2,0,2,0,2,0,0,0,1,1,0,0,0,0,0,2
data 2,0,0,1,1,1,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,0,1,0,0,0,0,0,0,2
data 2,0,0,1,1,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,1,0,0,0,0,0,0,2
data 2,0,0,1,1,0,0,2,0,2,0,2,0,2,0,2,0,0,0,2,0,1,1,1,0,0,0,0,0,2
data 2,0,0,1,1,1,1,1,1,1,1,0,2,0,2,0,0,0,2,0,0,1,1,1,0,0,0,0,0,2
data 2,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,2
data 2,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,3,1,1,1,0,0,0,0,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2
data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2
data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
`function stolen from Hobgoblin Lord (http://forum.thegamecreators.com/?m=forum_view&t=96232&b=6)
function make_midi(file as string,instrument as integer,tempo as integer,notes as string)
SPEED=135
notes=" "+notes
for a = 1 to len(notes)
watch$=mid$(notes,a)
if watch$=" "
start=a:test_note$=""
repeat
inc start
new$=mid$(notes,start)
if new$<>" "
test_note$=test_note$+new$
endif
until new$=" " or start=len(notes)
note_on=1
if len(test_note$)=1
select lower$(test_note$)
case "q":SPEED=135:endcase
case "8":speed=134:endcase
case "h":speed=140:endcase
case "r":array insert at bottom master_note():count=array count(master_note())
master_note(count).note=0:master_note(count).speed=SPEED:master_note(count).volume=0
endcase
endselect
note_on=0
else
temp_note$=left$(test_note$,1):temp_octave=val(right$(test_note$,1))
select lower$(temp_note$)
case "c":note_base=0:endcase
case "d":note_base=2:endcase
case "e":note_base=4:endcase
case "f":note_base=5:endcase
case "g":note_base=7:endcase
case "a":note_base=9:endcase
case "b":note_base=11:endcase
endselect
inc note_base,Temp_octave*12
if len(test_note$)=3 then inc note_base
endif
if note_on=1
array insert at bottom master_note()
count=array count(master_note())
master_note(count).note=note_base
master_note(count).speed=SPEED
master_note(count).volume=127
endif
endif
next a
`figure bytes in the track
track_total=20+((array count(master_note())+1)*9)
if file exist("making_bytes.txt")=1 then delete file "making_bytes.txt"
open to write 1,"making_bytes.txt"
write long 1,track_total
close file 1
open to read 1,"making_bytes.txt"
read byte 1,track_bytesD
read byte 1,track_bytesc
read byte 1,track_bytesB
read byte 1,track_bytesA
close file 1
`create the actual midi file
file=file+".mid"
if file exist(file)=1 then delete file file
open to write 1,file
`write the header
write byte 1,77:write byte 1,84:write byte 1,104:write byte 1,100:write byte 1,0:write byte 1,0:write byte 1,0:write byte 1,6
write byte 1,0:write byte 1,0:write byte 1,0:write byte 1,1
`write track header
write byte 1,TEMPO:write byte 1,192 `affects duration
write byte 1,77:write byte 1,84:write byte 1,114:write byte 1,107
`number of bytes in the track
write byte 1,track_bytesa:write byte 1,track_bytesb:write byte 1,track_bytesc:write byte 1,track_bytesd
`instrument and delta set up
write byte 1,0:write byte 1,192:write byte 1,INSTRUMENT `instrument
write byte 1,0:write byte 1,255:write byte 1,89:write byte 1,2:write byte 1,0:write byte 1,0:write byte 1,0:write byte 1,255:write byte 1,81:write byte 1,3:write byte 1,9:write byte 1,39:write byte 1,192:write byte 1,0
`write the notes
`turn the note on
for count = 0 to array count(master_note())
write byte 1,144:write byte 1,master_note(count).note:write byte 1,master_note(count).volume:write byte 1,master_note(count).speed:write byte 1,64
`turn it off
write byte 1,128:write byte 1,master_note(count).note:write byte 1,0:write byte 1,0
next count
`write track end
write byte 1,255,:write byte 1,47,:write byte 1,0,:write byte 1,1
close file 1
endfunction
function make_image_memblock(memblock,width,height,depth)
make memblock memblock,width*height*depth*4+12
write memblock dword memblock,0,width
write memblock dword memblock,4,height
write memblock dword memblock,8,depth
endfunction
function memblock_dot(memblock,xcoord,ycoord,colour as dword)
width=memblock dword(memblock,0)
write memblock dword memblock,((ycoord-1)*width+xcoord-1)*4+12,colour
endfunction
function memblock_line(memblock,x1,y1,x2,y2,colour as dword)
width=memblock dword(memblock,0)
if abs(x2-x1)>abs(y2-y1)
m#=(y2-y1+0.0)/(x2-x1+0.0)
b#=y1-m#*x1
minx=min(x1,x2)
maxx=max(x1,x2)
for ix=minx to maxx
iy=int(m#*ix+b#+0.5)
write memblock dword memblock,((iy-1)*width+ix-1)*4+12,colour
next ix
else
miny=min(y1,y2)
maxy=max(y1,y2)
if x2=x1
for iy=miny to maxy
write memblock dword memblock,((iy-1)*width+x1-1)*4+12,colour
next iy
else
m#=(x2-x1+0.0)/(y2-y1+0.0)
b#=y1-1/m#*x1
for iy=miny to maxy
ix=int(m#*(iy-b#)+0.5)
write memblock dword memblock,((iy-1)*width+ix-1)*4+12,colour
next ix
endif
endif
endfunction
function memblock_circle(memblock,centerx,centery,radius,colour as dword)
bx=centerx-radius
py1=centery+sqrt(radius^2-(bx-centerx)^2)
py2=centery-sqrt(radius^2-(bx-centerx)^2)
ex=centerx+radius
width=memblock dword(memblock,0)
size=get memblock size(1)
for x=bx to ex
y1=centery+sqrt(radius^2-(x-centerx)^2)
y2=centery-sqrt(radius^2-(x-centerx)^2)
miny=min(py1,y1)
maxy=max(py1,y1)
for y=miny to maxy
pos=((y-1)*width+x-1)*4+12
if pos>11 and pos<size
write memblock dword memblock,pos,colour
endif
next y
miny=min(py2,y2)
maxy=max(py2,y2)
for y=miny to maxy
pos=((y-1)*width+x-1)*4+12
if pos>11 and pos<size
write memblock dword memblock,pos,colour
endif
next y
py1=y1
py2=y2
next x
endfunction
function min(value1#,value2#)
if value1#<value2#
a#=value1#
else
a#=value2#
endif
endfunction a#
function max(value1#,value2#)
if value1#>value2#
a#=value1#
else
a#=value2#
endif
endfunction a#
I've attached the exe my computer makes when it runs this, I don't know why it wouldn't work on your computer.