Bullet Spray routines

Share graphical tips, notes and queries related to our favourite screen layout and its editors.
User avatar
ParadigmShifter
Manic Miner
Posts: 670
Joined: Sat Sep 09, 2023 4:55 am

Re: Bullet Spray routines

Post by ParadigmShifter »

Normalise just makes a vector have a length of 1, so in 2d it's

let length = sqrt(v.x*v.x + v.y*v.y) // Pythagoras
v.x = v.x / length
v.y = v.y / length



v.x * vx + v.y * v.y is also dot_product(v, v)

dot product just tells you the cosine of the angle between 2 vectors, as long as they are both normalised (otherwise it's length(a)*length(b)*cos(angle between a and b)).

You can use dot product for many other things though like projecting lines onto other lines so worth reading up about.

You could do super sprint AI by doing several raycasts in an arc around the car and if they hit anything try and turn to avoid collisions, so like a robot car with sensors attached. Doing the raycast is quite expensive I expect though on a speccy.

Most simple racing games either use on rails CPU or else they provide spline "tracks" like scalextric which you can use to change track for overtaking and collision avoidance etc. (so you'd have say 5 splines parallel-ish to each other and provide a routine to swap between splines as you drive along).

I think Graphics Gems is available online which has most of the maths you need to do geometry stuff like ray-circle collision, raycasts, etc.

Yup, you can read that here (dunno if that's 100% legal, mods can remove the link if it isn't) ;)

https://theswissbay.ch/pdf/Gentoomen%20 ... ms%201.pdf
Wall_Axe
Manic Miner
Posts: 500
Joined: Mon Nov 13, 2017 11:13 pm

Re: Bullet Spray routines

Post by Wall_Axe »

Thanks it's worth a look .

I suppose one way would be to project the computers car into the future if three different actions were taken and use the best.
Although if the car crashed and was facing backwards it would need to do stuff which would seem bad to a short term prediction algorithm. So maybe it could be used if the car is facing or moving in the right direction to the next invisible checkpoint.

And just loads of custom code to get a car going again...or detect a crash and teleport the enemy car back on the track.
User avatar
lexi
Dizzy
Posts: 63
Joined: Mon Dec 04, 2023 10:55 pm
Contact:

Re: Bullet Spray routines

Post by lexi »

ParadigmShifter wrote: Fri Dec 08, 2023 7:35 pm Missed that joke first time around lol ;) Here's 2 more
i giggled :D
DoctorRad
Drutt
Posts: 27
Joined: Mon Mar 18, 2024 4:40 pm

Re: Bullet Spray routines

Post by DoctorRad »

There doesn't appear to be a lot of awareness or appreciation of David Webb's book Advanced Spectrum Machine Language, which among other things, includes fast (pixel) plot and draw routines. The latter could probably be adapted into a straight-line bullet animation routine.
Post Reply