Re: Two questions about bgt

In the mathematical sense, vectors describe a magnitude and a direction. This can be used to represent position, as well as velocity, force, etc.

In BGT, vectors contain member variables x, y, and optionally z.
Most of the more complicated features come into play for physics simulations, and for audio games we can ignore quite a lot.

You'd treat vectors like other objects. For example:

// Create vectors for player position and velocity:
vector player_position(0, 0,0);
vector player_velocity(0, 0, 0);

// Set velocity to something simple, like moving to the right at 3m/s:
player_velocity.x=3.0;
// (It's possible to work in angles, rotation, etc, but this is more complicated. I'd recommend math.bgt from my includes.zip, as it has more functions for working with vectors.

// A function for getting the position of an actor (player or enemy or even bullets), given position, velocity, and time:
// This takes advant age of features of BGT's vectors
vector next_position(vector position, vector velocity, double dt) {
// (Note: time is in seconds.)
return position+(velocity*dt);
}


To be honest, I've never actually tried that trick, but I usually use geometric shapes instead of a point position vector.
If you want to update the player position using that function:

// There are different ways to get dt, depending on how your game is set up.
// If you have a game timer, it might be
// double dt=game_timer.elapsed/1000.0;

player_position=next_position(player_position, player_velocity, dt);

However, you'd want to check if the movement would go through solid objects.
It's hard to say what the best map design would be for any particular game. Tile arrays, object lists, even a shallow version of scene graphs (which are probably how most mainstream 3D games do it, but most implementations I've found are horribly complicated. This is probably because I prefer objects to represent objects or attributes, and methods to represent actions, and the scene graph implementations I've studied have it as objects all the way down. with multiple layers of abstraction and overly elaborate class names and the need to constantly check the documentation for the parameter lists for each and every level. ... You probably can get away with a tile array.)

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Alan via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector

Reply via email to