Working Lite_c radar

Posted By: Realspawn

Working Lite_c radar - 03/27/16 01:03

I've been searching a long time for a working radar in lite_c
a radar that shows the player in the middle and all the enemy entities as red dots.

I found some in the old forum but there wdl and the stuff in this forum
has radar topics but none get fully answered or shows one that reallt works laugh

So if some one could provide a working example we will be more the happy with it for sure laugh
Posted By: EpsiloN

Re: Working Lite_c radar - 03/27/16 05:44

It shouldn't be hard to implement it. Here's an idea:

decide how far you're gonna display enemies (for example 1000 quants). Put an image and for every enemy that is closer than 1000 quants to the player pan_create a dot (save the pointer in an enemy skill, so you can move the pan) and have a function that checks the enemy position, subtracts that position and scales by a factor to fit on your radar image on the screen. When you subtract, if the enemy is (for example) behind the player, you get negative X and the dot will move in the negative direction. The only trouble is that, you have to center this position on the center of your radar...
If you want it rotating with your player, you'll have to multiply the final screen position with cos and sin player pan.
By the way, no need to convert in any way the X/Y of the radar, because you're already using X and Y in world coordinates, I think.

And that's it laugh no math at all.
Posted By: Reconnoiter

Re: Working Lite_c radar - 03/27/16 14:39

Similar to a minimap but than relative to the player's position.

Or you can e.g. use a VIEW for it use the NOFLAGs for you radar view and camera view to show & hide what you want on them.
Posted By: Realspawn

Re: Working Lite_c radar - 03/27/16 22:16

All good plans yet still i lack the skills to master this
i will keep trying but hope to figure it out soon as it is
the last thing my upcoming game need laugh
Posted By: EpsiloN

Re: Working Lite_c radar - 03/28/16 05:20

Assume your radar is positioned at X=100,Y=100 on screen and its wide 300px in diameter.
In the enemy function add code to create a panel and display it:
Code:
if(vec_dist(my.x,player.x) < 1000) {
    // No dot exists for me
    if(my.skill44 == 0) {
        PANEL* tmpPan = pan_create(a dot :));
        my.skill44 = tmpPan;
    } else {
        // A dot exists, correct its position
        PANEL* tmpPan = my.skill44;
        tmpPan.x = (radar.x + 150) + (player.x - my.x) * 6.67;
        tmpPan.y = (radar.y + 150) + (player.y - my.y) * 6.67;
        // Too lazy to check the math, cuz I got drunk and I have a headache
        // 1000(dist from player) / 150(radius of radar pan) = ~6.67, do the opposite 1000/6.67 and it becomes 150px. 500/6.67 gives 75 pixels...
    }
} else {
    // If I'm at a distance, but a dot exists
    // remove it...
    if(my.skill44 != 0) {
        PANEL* tmpPan = my.skill44;
        ptr_remove(tmpPan);
        my.skill44 = 0;
    }
}



All this is not tested and if I have a typo it should be easy to fix, but this should give you the starting point...

The problem comes when you want to use it in multiplayer and don't want to use the "player" pointer laugh You have to do it differently... But for a single player game it should work.

PS.: To do an oriented radar you'll have to play with sin(player.pan) and cos(player.pan) on the final dot position on the screen, after you've placed it...

Oh, my head frown
Posted By: txesmi

Re: Working Lite_c radar - 03/28/16 15:04

I created one some time ago: download

Salud!
Posted By: Realspawn

Re: Working Lite_c radar - 03/28/16 15:36

That one looks excellent grin thank you for sharing it laugh
© 2024 lite-C Forums