Search found 34 matches

by thebigh
Apr 18, 2020 15:28
Forum: Community Discussion
Topic: What do you use FreeBASIC for?
Replies: 91
Views: 3819

Re: What do you use FreeBASIC for?

I'm trying and failing to make a game with FreeBASIC and OpenGL.
by thebigh
Apr 13, 2020 13:06
Forum: General
Topic: Squares
Replies: 7926
Views: 495698

Re: Squares

Yes. This shows clearly what's going on:

Code: Select all

dim as short i
for i = 0 to 255
next i
print i


Now try putting 256 in a ubyte.
by thebigh
Apr 13, 2020 12:22
Forum: General
Topic: Squares
Replies: 7926
Views: 495698

Re: Squares

Here's my derp moment of the day dim as ubyte i for i = 0 to 255 do_something_with( i ) lots_of_lines_of_complex_code( i ) tedious_blather( i ) next i Scratching my head why this loop ran forever. Was something in my many dozens of lines of complex code causing i to be changed from within the loop s...
by thebigh
Apr 06, 2020 22:35
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

The last thing we need is a wrapper routine for all of this stuff that you can call from your main game loop. First reset colpak with suitable values: sub reset_colpak( byref colpak as collision_packet, byval player_position as point3d, byval player_velocity as point3d,_ byval player_angle as angles...
by thebigh
Apr 06, 2020 22:34
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

Just as we used the arguments in lowest_positive_root to keep track of the first collision among a single triangle's vertices and edges, we will use the colpak structure to store the information about the earliest collision among all the triangles tested so far. That goes into colpak.coll.epoint and...
by thebigh
Apr 06, 2020 22:33
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

Finally we can put all this together to test for a collision with a single given triangle. Here it is. Most of it will be explained in the many comments I have put in there. sub check_triangle( tri() as point3d, colpak as collision_packet ptr ) 'only two arguments; most of what we need is in colpak ...
by thebigh
Apr 06, 2020 22:33
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

If we don't hit the triangle on its face, we might still collide with a corner or an edge. Detecting a vert collision is relatively easy conceptually, but comes with a little bit of bookkeeping. All we need is, for any given vertex, to determine when and if its distance to the sphere is equal to one...
by thebigh
Apr 06, 2020 22:32
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

If a sphere hits the interior of a triangle, it will do so *before* it ever strikes an edge or a vertex. Play around with a marble and paper scraps if you like and you'll see it's true. Now, a triangle is just a small part of an infinite plane containing its three corners so first we'll see if the s...
by thebigh
Apr 06, 2020 22:30
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

Now the next stage, and possibly the trickiest: detecting whether Mr. Sphere has bumped up against a triangle. There are three possible collision types. You can hit the face of the triangle, an edge, or a corner. Each of these needs to be checked for. The first thing to do is pass the algorithm info...
by thebigh
Apr 06, 2020 22:30
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Re: Collision detection in 3D

From now on I'll call the original space R3 and the scaled one eSpace. So how do we perform this coordinate transform? Just scale the coordinates of all the points in the world along the axes of the ellipsoid. That is, if your original ellipsoid has a radius of 0.5 along the x axis you need to multi...
by thebigh
Apr 06, 2020 22:29
Forum: Game Dev
Topic: Collision detection in 3D
Replies: 10
Views: 500

Collision detection in 3D

Hello FreeBASIC enthusiasts. For a while now I have been wrestling with getting collision detection working in my attempt to write a 3D game in FreeBASIC and OpenGL. I've probably deleted and rewritten the sorry thing three or four times now but, since it now more-or-less works I thought I'd run thr...
by thebigh
Apr 04, 2020 12:09
Forum: Beginners
Topic: I started a blog to learn FreeBASIC through videogames
Replies: 16
Views: 1099

Re: I started a blog to learn FreeBASIC through videogames

My style has always been to put spaces around +, -, and = but no spaces around multiplication and division. I personally find that easier to read, but of course nothing much can help against typos.
by thebigh
Apr 04, 2020 9:56
Forum: Beginners
Topic: I started a blog to learn FreeBASIC through videogames
Replies: 16
Views: 1099

Re: I started a blog to learn FreeBASIC through videogames

*%#§)% 90% frustration Like ripping up and rewriting the algorithm three or four times, certain that the reason I was skidding up walls and falling through the floor was an arcane mathematical subtlety... and then going back to my basic linear algebra functions to find I've done this stupid stupid ...
by thebigh
Apr 03, 2020 22:08
Forum: General
Topic: Strange behaviour with #define
Replies: 8
Views: 332

Re: Strange behaviour with #define

I suppose that's a good thing, actually. Imagine if you *needed* a leading space for some reason and couldn't otherwise get one-- because the preprocessor would interpret a leading space as a separator between tokens instead of being part of a token itself, or compress consecutive spaces into one. N...
by thebigh
Apr 03, 2020 21:02
Forum: General
Topic: Strange behaviour with #define
Replies: 8
Views: 332

Re: Strange behaviour with #define

marcov wrote:In C preprocessor you have to use # or ## to concatenate and form aggregates of two parts. Maybe in FB too?


There is a concatenate operator ## that concatenates at the preprocessor stage, but AFAICT it has the same issue with spurious spaces.

Go to advanced search