hi, i am VERY confused right now. I've been trying to recreate slot cars in tic, but the checkpoint style race code I've tried will result in the car overshooting the checkpoint that tells it to go to the next spot, and stopping right below the checkpoint by one or more pixel, UNLESS the speed its traveling at is a number you would get by continuing this sequence:0.5,1,2,4,8,16. I am attempting to make it so that when you press [z] then it makes the car go faster, but if you let go, it slowly decreases. also, the locP1={...} are the locations of the checkpoints that tell it to go to the next. point is the variable that tells it which one to be going towards. if you need the tic file, just ask. if you are confused by this description, just please look at the code.
ALSO, I WOULD PREFER TO HAVE ANY HELP BE MODS OF THE CODE, BECAUSE MOST OF LUA IS CONFUSING FOR ME, AND ITS HARD TO LOOK AT EXAMPLES AND FIGURE OUT WHAT THEY ARE SAYING.
CODE:
--slot cars
--vars
--PLR1,1plrmode
plrx=0
plry=0
--gamemode, 0=jackj106 logo,
--1=home,2=1plrmode,3=2plr mode.
mode=1
--tiles & LOCALS
t=0
sa=1
local tiles={
CORNER01=176,
TOP=177,
CORNER02=178,
RIGHT=194,
CORNER03=210,
BOTTOM=209,
CORNER04=208,
LEFT=192,
TURN01=179,
TURN02=180,
TURN03=195,
TURN04=196,
FLAMES=183
}
local locP1={
x1=16+1,
y1=88+1,
x2=40+1,
y2=88+1,
x3=40+1,
y3=96+1,
x4=96+1,
y4=96+1,
x5=96+1,
y5=32+1,
x6=136+1,
y6=32+1,
x7=136+1,
y7=104+1,
x8=192+1,
y8=104+1,
x9=224+1,
y9=72+1,
x10=128+1,
y10=56+1,
x11=48+1,
y11=16+1,
x12=48+1,
y12=32+1,
x13=16+1,
y13=32+1,
x14=16+1,
y14=56+1
}
local point=1
local lap=1
ti=0
--slot car xy
sx=16
sy=40
--angle
an=1
sa=0
--speed
spd=0.5
spddiv=1
spdx=0.5
spdy=0
--home message
hm="[Z]:1Player mode/[X]:2Player mode"
--difficulty
diff=0
diffno="None selected"
--global vars
function TIC()
cls(0)
if mode==0 then cls(0)
map()
end
if mode==1 then cls(0)
map(30,1,30,16,0,0)
print(hm,24,76)
if btn(4) then hm="Select a CPU difficulty:"
end
if hm=="Select a CPU difficulty:" then print("1",24,84)
print("2",48,84)
print("3",72,84)
print("Use ^:1 , <:2 , >:3",24,92)
print("Currently set to:",24,100)
print(diffno,128,100)
if btn(0) then diff=1
diffno="1"
end
if btn(2) then diff=2
diffno="2"
end
if btn(3) then diff=3
diffno="3"
end
print("Once chosen, press[Z]",24,108)
end
if diff>0 then t=t+1
if btn(4) then mode=2 end
end
end
if mode==2 then cls(0)
map(60,0,30,16,0,0)
spr(sa,sx,sy,0,1,0)
if point>0 then t=t+1
if point==1 then t=t+1
if sy<locP1.y1 then sy=sy+spd/spddiv
sa=5
end
if sy==locP1.y1 then point=point+1 end
end
if point==2 then t=t+1
if sx<locP1.x2 then sx=sx+spd/spddiv
sa=1
end
if sx==locP1.x2 then point=point+1 end
end
if point==3 then t=t+1
if sy<locP1.y3 then sy=sy+spd/spddiv
sa=5
end
if sy==locP1.y3 then point=point+1 end
end
if point==4 then t=t+1
if sx<locP1.x4 then sx=sx+spd/spddiv
sa=1
end
if sx==locP1.x4 then point=point+1 end
end
if point==5 then t=t+1
if sy>locP1.y5 then sy=sy-spd/spddiv
sa=13
end
if sy==locP1.y5 then point=point+1 end
end
if point==6 then t=t+1
if sx<locP1.x6 then sx=sx+spd/spddiv
sa=1
end
if sx==locP1.x6 then point=point+1 end
end
if point==7 then t=t+1
if sy<locP1.y7 then sy=sy+spd/spddiv
sa=5
end
if sy==locP1.y7 then point=point+1 end
end
if point==8 then t=t+1
if sx<locP1.x8 then sx=sx+spd/spddiv
sa=1
end
if sx==locP1.x8 then point=point+1 end
end
if point==9 then t=t+1
if sx<locP1.x9 then sx=sx+spd/spddiv
sa=15
end
end
if point==9 then t=t+1
if sy>locP1.y9 then sy=sy-spd/spddiv
sa=15
end
if sy==locP1.y9 then point=point+1 end
end
if point==10 then t=t+1
if sy>locP1.y10 then sy=sy-spd/spddiv
sa=13
end
if sy==locP1.y10 then point=point+1 end
end
if point==11 then t=t+1
if sy>locP1.y11 then sy=sy-spd/spddiv
sa=11
end
if sy==locP1.y11 then point=point+1 end
end
if point==11 then t=t+1
if sx>locP1.x11 then sx=sx-spd/spddiv
end
end
if point==12 then t=t+1
if sx>locP1.x12 then sx=sx-spd/spddiv
sa=9
end
if sx==locP1.x12 then point=point+1
end
end
if point==13 then t=t+1
if sx>locP1.x13 then sx=sx-spd/spddiv
sa=7
end
if sx==locP1.x13 then point=point+1 end
end
if point==13 then t=t+1
if sy<locP1.y13 then sy=sy+spd/spddiv end
end
if point==14 then t=t+1
if sy<locP1.y14 then sy=sy+spd/spddiv
sa=5
end
if sy==locP1.y14 then point=1 end
end
if btn(4) then spd=spd+0.5 end
end
end
if spd>0.5 then spd=spd-0.25 end
end