Ja, that Bump N Go code came from here (I did use arrow keys, I do have them but up and down are between left and right and only half size keys. Not the best setup for arrow pounding games.) Up and down are for gas and breaks.
_Title "Drive Car" 'b+ 2021-09-29
blue.w = 20: blue.h = 40
blue.ra
= _Pi / 2: blue.speed
= 2blue.c = 9
CarAngle
= CarAngle
+ _D2R(s
) Case 18432 'arrow UP is gas blue.speed = blue.speed + .1
If blue.speed
> 5 Then blue.speed
= 5 Case 20480 'arrow DOWN slow down blue.speed = blue.speed - .1
If blue.speed
< 0 Then blue.speed
= 0 s = s + 2 'to right
s = s - 2 'to left
blue.x
= blue.x
+ blue.speed
* Cos(blue.ra
) blue.y
= blue.y
+ blue.speed
* Sin(blue.ra
) drawCar blue
' code not optimized for speed just proff of concept
X1
= a.x
+ a.h
/ 2 * Cos(a.ra
) Y1
= a.y
+ a.h
/ 2 * Sin(a.ra
) X2
= X1
+ a.w
/ 2 * Cos(a.ra
+ _Pi / 2) Y2
= Y1
+ a.w
/ 2 * Sin(a.ra
+ _Pi / 2) X3
= X1
+ a.w
/ 2 * Cos(a.ra
- _Pi / 2) Y3
= Y1
+ a.w
/ 2 * Sin(a.ra
- _Pi / 2)
x4
= a.x
+ a.h
/ 2 * Cos(a.ra
- _Pi) y4
= a.y
+ a.h
/ 2 * Sin(a.ra
- _Pi) x5
= x4
+ a.w
/ 2 * Cos(a.ra
+ _Pi / 2) y5
= y4
+ a.w
/ 2 * Sin(a.ra
+ _Pi / 2) x6
= x4
+ a.w
/ 2 * Cos(a.ra
- _Pi / 2) y6
= y4
+ a.w
/ 2 * Sin(a.ra
- _Pi / 2)
Line (X2
, Y2
)-(X3
, Y3
), a.c
Line (X3
, Y3
)-(x6
, y6
), a.c
Line (x6
, y6
)-(x5
, y5
), a.c
Line (x5
, y5
)-(X2
, Y2
), a.c
Paint (a.x
, a.y
), a.c
, a.c
Line (X2
, Y2
)-(X3
, Y3
), 15 ' give car a front
' white top for all cars for future numbers maybe
X1
= a.x
+ a.h
/ 4 * Cos(a.ra
) Y1
= a.y
+ a.h
/ 4 * Sin(a.ra
) X2
= X1
+ (a.w
/ 2 - 3) * Cos(a.ra
+ _Pi / 2) Y2
= Y1
+ (a.w
/ 2 - 3) * Sin(a.ra
+ _Pi / 2) X3
= X1
+ (a.w
/ 2 - 3) * Cos(a.ra
- _Pi / 2) Y3
= Y1
+ (a.w
/ 2 - 3) * Sin(a.ra
- _Pi / 2)
x4
= a.x
+ a.h
/ 4 * Cos(a.ra
- _Pi) y4
= a.y
+ a.h
/ 4 * Sin(a.ra
- _Pi) x5
= x4
+ (a.w
/ 2 - 3) * Cos(a.ra
+ _Pi / 2) y5
= y4
+ (a.w
/ 2 - 3) * Sin(a.ra
+ _Pi / 2) x6
= x4
+ (a.w
/ 2 - 3) * Cos(a.ra
- _Pi / 2) y6
= y4
+ (a.w
/ 2 - 3) * Sin(a.ra
- _Pi / 2)
Line (X2
, Y2
)-(X3
, Y3
), 15 Line (X3
, Y3
)-(x6
, y6
), 15 Line (x6
, y6
)-(x5
, y5
), 15 Line (x5
, y5
)-(X2
, Y2
), 15
I think I had plans to put car(s) on track and drive them for best time? Every time you go off the track you add to your time unless you crash and die, then times up, game over you've gone home.
Don't buy insurance don't want the wife too happy you are dead.
Nice job with the turning Ken!