|
|
|
|
|
|
|
|
SGT_FW
by Aku_Aku. 05/31/26 11:05
|
|
|
|
|
XTB
by pr0logic. 05/18/26 12:27
|
|
|
1 registered members (TipmyPip),
3,506
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
How is this done ? Track map
#422921
05/20/13 11:44
05/20/13 11:44
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP

Expert
|
OP

Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
I am currently still toying with an other small workshop demo. Now looking at other fun kart games i noticed the map shown where you see the racers move over. Has anyone an idea how this is done ? how to create the white line that represents the track and show the racers on it ? Here is what i have so far and still working on  A lot to do yet but it will be a fun little demo for noobs like me http://www.youtube.com/watch?v=Tj--5bcNX7g&feature=youtu.be
|
|
|
Re: How is this done ? Track map
[Re: Realspawn]
#422923
05/20/13 13:48
05/20/13 13:48
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
I would create the minimap bmap into a bmap_process, but needles are created exactly for this 
#include <acknex.h>
VECTOR vecTemp;
ANGLE angTemp;
PANEL *panMinimap;
BMAP *bmpMinimap, *bmpCar;
var needleIndex = 3;
action actCar ()
{
pan_setneedle ( panMinimap, 0, 256, 256, bmpCar, 16, 16, 90, 0, 360, my->skill1 );
var myIndex = needleIndex;
needleIndex += 1;
while (1)
{
vec_diff ( &vecTemp, camera->x, my->x );
vec_normalize ( &vecTemp, 3 * time_step );
vec_add ( &my->x, &vecTemp );
vec_to_angle ( &angTemp, &vecTemp );
my->pan = angTemp.pan;
vecTemp.x = ( camera->x - my->x ) * panMinimap->skill_y;
vecTemp.y = -( camera->y - my->y ) * panMinimap->skill_y;
my->skill1 = ang ( my->pan - camera->pan );
vec_rotate ( &vecTemp, vector ( 90-panMinimap->skill_x, 0, 0 ) );
pan_setneedle ( panMinimap, myIndex, 256+vecTemp.x, 256+vecTemp.y, bmpCar, 16, 16, 90, 0, 360, my->skill1 );
wait(1);
}
}
function main ()
{
video_mode = 10;
fps_max = 30;
wait(1);
bmpMinimap = bmap_create ( "minimap.tga" );
bmpCar = bmap_create ( "player.tga" );
panMinimap = pan_create ( "flags=SHOW;", 1 );
pan_setneedle ( panMinimap, 0, 256, 256, bmpMinimap, 256, 256, 90, 0, 360, panMinimap->skill_x );
pan_setneedle ( panMinimap, 0, 256, 256, bmpCar, 16, 16, 90, 0, 360, camera->skill_x );
panMinimap->bmap = bmap_createblack ( 512, 512, 24 );
panMinimap->target_map = bmap_createblack ( 512, 512, 24 );
PANEL *panMap = pan_create ( "flags=SHOW", 1 );
panMap->bmap = panMinimap->target_map;
level_load ( "ground.mdl" );
camera->z = 20;
c_setminmax ( level_ent );
panMinimap->skill_y = bmap_width ( bmpMinimap ) / ( level_ent->max_x * 2 ) ;
int i = 0;
for ( ; i<10; i++ )
ent_create ( SPHERE_MDL, vector(random(1024)-512, random(1024)-512, 10 ), actCar );
while ( !key_esc )
{
proc_mode = PROC_EARLY;
camera->pan -= mickey.x * 0.2;
vec_set ( &vecTemp, vector (key_cuu-key_cud, key_cul-key_cur, 0) );
vec_normalize ( &vecTemp, 10*time_step );
vec_rotate ( &vecTemp, vector(camera->pan,0,0) );
vec_add ( &camera->x, &vecTemp );
panMinimap->skill_x = -camera.pan;
vecTemp.x = camera->x * panMinimap->skill_y;
vecTemp.y = -camera->y * panMinimap->skill_y;
pan_setneedle ( panMinimap, 1, 256, 256, bmpMinimap, 256+vecTemp.x, 256+vecTemp.y, 90, 0, 360, panMinimap->skill_x );
wait(1);
}
sys_exit ( NULL );
}
DOWNLOAD (code & resources)
Last edited by txesmi; 05/20/13 14:06. Reason: link added
|
|
|
Re: How is this done ? Track map
[Re: Realspawn]
#422936
05/21/13 07:42
05/21/13 07:42
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
I will try to explain what is done into that code. I create the panels in run time in the first steps of main 'funtion':
bmpMinimap = bmap_create ( "minimap.tga" );
bmpCar = bmap_create ( "player.tga" );
panMinimap = pan_create ( "flags=SHOW;", 1 );
pan_setneedle ( panMinimap, 0, 256, 256, bmpMinimap, 256, 256, 90, 0, 360, panMinimap->skill_x );
pan_setneedle ( panMinimap, 0, 256, 256, bmpCar, 16, 16, 90, 0, 360, camera->skill_x );
panMinimap->bmap = bmap_createblack ( 512, 512, 24 );
panMinimap->target_map = bmap_createblack ( 512, 512, 24 );
PANEL *panMap = pan_create ( "flags=SHOW", 1 );
panMap->bmap = panMinimap->target_map;
There are two panels. 'panMiniMap' is used to contain all the needles used for the minimap and is rendered over its 'render_target'. 'panMap' is just used to show the main panel 'render_target'. I did it this way becuase the needle member of a panel is also rendered out of the bounds of the panel when it gets out of it, and this way just the part inside its panel bounds will be shown. Initially, 'panMinimap' has two needles: the first one is the map itself, and the second is the player icon. I used 'panMinimap->skill_x' for the needle orientation. I set 'panMinimap->skill_y' as the proportion between the minimap bitmap size and the level size in order to compute the needle pivot:
panMinimap->skill_y = bmap_width ( bmpMinimap ) / ( level_ent->max_x * 2 ) ;
...
while ( !key_esc )
...
proc_mode = PROC_EARLY;
...
panMinimap->skill_x = -camera.pan;
vecTemp.x = camera->x * panMinimap->skill_y;
vecTemp.y = -camera->y * panMinimap->skill_y;
pan_setneedle ( panMinimap, 1, 256, 256, bmpMinimap, 256+vecTemp.x, 256+vecTemp.y, 90, 0, 360, panMinimap->skill_x );
I used 'proc_mode = PROC_EARLY' in order to ensure that the panel skills are computed first, so all other needles have the actual frames 'skill_x' and 'skill_y' values updated at their computation time. The needle angle allocated in 'skill_x'
panMinimap->skill_x = -camera.pan;
is the negative of the players 'pan', because the screen (and panels) coordinate system is clockwise while the world coordinate system is counterclockwise. With this issue in mind the Y coordinate of the offset of the background has to be computed same:
vecTemp.x = camera->x * panMinimap->skill_y;
vecTemp.y = -camera->y * panMinimap->skill_y; // inverse Y, so convert to counterclockwise coordinate system.
And finally inside 'main' we need to update the needle pivot position:
pan_setneedle ( panMinimap, 1, 256, 256, bmpMinimap, 256+vecTemp.x, 256+vecTemp.y, 90, 0, 360, panMinimap->skill_x );
With this few lines of code we have a minimap that rotates with the camera pan, and computes its offset with the camera position. The enemies icons are created into the first lines of the entity action:
var needleIndex = 3;
action actCar ()
{
pan_setneedle ( panMinimap, 0, 256, 256, bmpCar, 16, 16, 90, 0, 360, my->skill1 );
var myIndex = needleIndex;
needleIndex += 1;
...
I used a global int to store the amount of needles, so we know the actual enemys' needle to further computations by this count i inside the action while loop:
pan_setneedle ( panMinimap, myIndex, 256+vecTemp.x, 256+vecTemp.y, bmpCar, 16, 16, 90, 0, 360, my->skill1 );
The enemies icon needles are rotated from its center, so the only things to compute is the offset (vecTemp) from the player and its orientation (my->skill1).
vecTemp.x = ( camera->x - my->x ) * panMinimap->skill_y;
vecTemp.y = -( camera->y - my->y ) * panMinimap->skill_y; // inverse!
vec_rotate ( &vecTemp, vector ( 90-panMinimap->skill_x, 0, 0 ) );
my->skill1 = ang ( my->pan - camera->pan );
The offset vector (vecTemp) is rotated by '90-panMinimap->skill_x' because the icons are looking to the right (X positive), and in the minimap they look up. The angle of the enemies icon (my->skill1) is the difference to the players orientation because the minimap is already oriented with the player. that's all folks! I hope it helps  Salud!
|
|
|
Re: How is this done ? Track map
[Re: txesmi]
#422945
05/21/13 09:32
05/21/13 09:32
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
What I'd use:
Render the map into an image and use this image as map in the game.
This should be faster. If you want to I can try wether it actually works or not.
POTATO-MAN saves the day! - Random
|
|
|
Re: How is this done ? Track map
[Re: ventilator]
#422965
05/21/13 16:39
05/21/13 16:39
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
What I'm talking about is a pre-rendered image. This is what comes out when using my method:  (there are 2 additional, simple steps in gimp because bmap_process doesn't support alpha channels.)
Last edited by Kartoffel; 05/21/13 16:50.
POTATO-MAN saves the day! - Random
|
|
|
Re: How is this done ? Track map
[Re: Kartoffel]
#422966
05/21/13 16:52
05/21/13 16:52
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP

Expert
|
OP

Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
and what is that method ?  I see what you created but how ? is it exactly a bmap of the track made in wed ?
Last edited by Realspawn; 05/21/13 16:52.
|
|
|
Re: How is this done ? Track map
[Re: Realspawn]
#422967
05/21/13 16:56
05/21/13 16:56
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
i used some shaders and put the camera with the isomteric-flag above the track. But only the track has to be visible for this.
POTATO-MAN saves the day! - Random
|
|
|
|