GEuser's CGUI Lib: radar() - create a radar system

How to find or create sprites, graphics, sounds and music.

GEuser's CGUI Lib: radar() - create a radar system

Postby GEuser » Wed Feb 27, 2013 8:58 pm

GEuser's CGUI Lib: radar() - create a radar system

GEuser's CUSTOMIZABLE GUI LIBRARY: radar()

REPLACEMENT UPLOADED 04 April 2013

Demo Screenshot

Image

DOWNLOADS (Large size due to station images)

Linux:
radarDemo_lin.zip
(2.68 MiB) Downloaded 200 times


Mac:
radarDemo_mac.zip
(2.98 MiB) Downloaded 194 times


Windows:
radarDemo_win.exe
(3.47 MiB) Downloaded 237 times


Demo Resources:
radarResources.zip
(2.25 MiB) Downloaded 229 times


Symbol Template:-
Image

INTRODUCTION

Wanted to create away to auto-generate a simple radar scanning system for any normal/canvass actors. To be-able to zoom in & out and change the size of individual targets displayed in radar and change the size of the radar window itself.

The radar() function will do all the laborious work for you. All you have to do is supply the Actor you want to include for radar scanning with all the various settings. Note because this is passed by reference you need the ampersand (&) in front of the actor name (e.g. for an actor called monster1 use radar(&monster1,...); You can add as many actors in successive radar calls to see multiple items on a radar scan. Important to note that the erase() function is only called once at the start of the radar() calls to avoid clearing of a previous radar() call. In the demo at end of post I've chosen to put the radar() function in the draw actor event. You may want to put it somewhere else but then you would have to be responsible for updating the radar display yourself.

UPDATE INFORMATION

Have done a complete overhaul of function:-

1. Now includes centreTarget, an actor that can be passed in (remember to add '&' symbol to actors name radar(..., &actorname, ...) for centering in radar. This can be for the player or whatever that needs to remain in the centre of the radar when view moves. centreScale can be used to specify sizing in radar. Note, the actor for this should be parented to the view).

2. Added displayMode that allows you to see targets in radar as actor images or symbols (first part of color parameter is for symbol color). Currently, there is a choice of 30 default symbols. These can be replaced or new ones added to switch() statement in radar global code (can use symbol template provided above).

3. radarColors now allows colors to be passed in as hex character string (must be capitals). The string is 16 long for two colors including alphas. This saves me using 8 parameters for the colors so big improvement for color management. Format is RRGGBBAA (RR=red, GG=green, BB=blue, AA=Alpha). The color coding is different from that given by skyderiegn in my arcbar() thread. My coding can be adjusted to allow for 31 colors in a single function parameter!!!

Use this LINK for getting the right hex color codes (they come in capitals on website so makes its easier to insert but you will need to add the alpha bits):-
http://www.workwithcolor.com/hsl-color-picker-01.htm or http://www.favicon.cc/
let me know if you find a link for one with an alpha setting included.

4. Got rid of radarY & radarX because it was causing problems but don't need it anyway cos can move the canvass that creates the radar.

BASIC INFORMATION

Image
Image
Image
Image

GLOBAL CODE

Code: Select all
 void radar (int displayMode, Actor * centreTarget, Actor * radarTarget, double centreScale, double targetScale, double radarScale, int radarWidth, int radarHeight, char * radarColors, int  borderSize)
{
    char colorRegister[17]="A3DE4F40A3DE4F50";
    char hexCode[18]="0123456789ABCDEF";
    char * ptr_hex;
    char col1[3]="";
    char col2[3]="";

    char s=colorRegister[0];

    int ColorParts[8];

    int radar_i=0;
 
    // calcluate target positioning within radar (relative to view & scale settings)
    int posX=radarWidth/2+(radarTarget->x/radarScale)-((view.width/2)/radarScale)-(view.x/radarScale)+borderSize;
    int posY=radarHeight/2+(radarTarget->y/radarScale)-((view.height/2)/radarScale)-(view.y/radarScale)+borderSize;

    // calcluate central actors positioning within radar (relative to view & scale settings)
    int cenX=radarWidth/2+((centreTarget->width/2)/radarScale);
    int cenY=radarHeight/2+((centreTarget->height/2)/radarScale);

    // load in parsed colors
    strcpy(colorRegister, radarColors);
 
    // extract color components
    for(radar_i=0; radar_i<8; radar_i++)
    {
    //
        s=colorRegister[(radar_i*2)];
        ptr_hex=strchr(hexCode,s);
        sprintf(col1, "%d", ptr_hex-(hexCode));

        s=colorRegister[(radar_i*2)+1];
        ptr_hex=strchr(hexCode,s);
        sprintf(col2, "%d", ptr_hex-(hexCode));

        ColorParts[radar_i]=atoi(col1)*16 + atoi(col2);
    }
 
    //place central actor in middle of radar screen
    draw_from(centreTarget->name, cenX, cenY, centreScale);
 
    // check target within radar display limits
    if ((posX>-1*(radarTarget->width*targetScale)/2+borderSize)&&(posX<radarWidth+borderSize)&&(posY>-1*(radarTarget->height*targetScale)/2+borderSize)&&(posY<radarHeight+borderSize))
    {
        // Okay, draw target

        // check if target actor or symbol display required (displayMode)
 
        setpen(ColorParts[0], ColorParts[1], ColorParts[2], ColorParts[3]/255.0, 1);
 
        switch (displayMode)
        {
            // actor display wanted, display it at targetScale
            case 0:
                     draw_from(radarTarget->name, posX, posY, targetScale);
                     break;
 
            // symbol display wanted
            case 1:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     putpixel(posX-3, posY-3); putpixel(posX+3, posY-3);
                     moveto(posX-4, posY-2); lineto(posX-4, posY+2);
                     moveto(posX+4, posY-2); lineto(posX+4, posY+2);
                     putpixel(posX-3, posY+3); putpixel(posX+3, posY+3);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
                     break;
 
            case 2:
                     moveto(posX-4, posY-4); lineto(posX+4, posY-4);
                     moveto(posX-4, posY-4); lineto(posX-4, posY+4);
                     moveto(posX+4, posY-4); lineto(posX+4, posY+4);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     break;
 
            case 3:
                     putpixel(posX, posY-4);
                     putpixel(posX-1, posY-3); putpixel(posX+1, posY-3);
                     putpixel(posX-1, posY-2); putpixel(posX+1, posY-2);
                     putpixel(posX-2, posY-1); putpixel(posX+2, posY-1);
                     putpixel(posX-2, posY); putpixel(posX+2, posY);
                     putpixel(posX-3, posY+1); putpixel(posX+3, posY+1);
                     putpixel(posX-3, posY+2); putpixel(posX+3, posY+2);
                     putpixel(posX-4, posY+3); putpixel(posX+4, posY+3);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     break;

             case 4:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     putpixel(posX-3, posY-3); putpixel(posX+3, posY-3);
                     moveto(posX-4, posY-2); lineto(posX-4, posY+2);
                     moveto(posX+4, posY-2); lineto(posX+4, posY+2);
                     putpixel(posX-3, posY+3); putpixel(posX+3, posY+3);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
                     moveto(posX-1, posY-2); lineto(posX+1, posY-2);
                     moveto(posX-2, posY-1); lineto(posX+2, posY-1);
                     moveto(posX-2, posY); lineto(posX+2, posY);
                     moveto(posX-2, posY+1); lineto(posX+2, posY+1);
                     moveto(posX-1, posY+2); lineto(posX+1, posY+2);
                     break;

             case 5:
                     moveto(posX-4, posY-4); lineto(posX+4, posY-4);
                     moveto(posX-4, posY-4); lineto(posX-4, posY+4);
                     moveto(posX+4, posY-4); lineto(posX+4, posY+4);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     moveto(posX-2, posY-2); lineto(posX+2, posY-2);
                     moveto(posX-2, posY-1); lineto(posX+2, posY-1);
                     moveto(posX-2, posY); lineto(posX+2, posY);
                     moveto(posX-2, posY+1); lineto(posX+2, posY+1);
                     moveto(posX-2, posY+2); lineto(posX+2, posY+2);
                     break;

            case 6:
                     putpixel(posX, posY-4);
                     putpixel(posX-1, posY-3); putpixel(posX+1, posY-3);
                     putpixel(posX-1, posY-2); putpixel(posX+1, posY-2);
                     putpixel(posX-2, posY-1); putpixel(posX+2, posY-1);
                     putpixel(posX-2, posY); putpixel(posX+2, posY);
                     putpixel(posX-3, posY+1); putpixel(posX+3, posY+1);
                     putpixel(posX-3, posY+2); putpixel(posX+3, posY+2);
                     putpixel(posX-4, posY+3); putpixel(posX+4, posY+3);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     putpixel(posX, posY-1); putpixel(posX, posY);
                     moveto(posX-1, posY+1); lineto(posX+1, posY+1);
                     moveto(posX-1, posY+2); lineto(posX+1, posY+2);
                     break;
 
            case 7:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     moveto(posX-3, posY-3); lineto(posX+3, posY-3);
                     moveto(posX-4, posY-2); lineto(posX-2, posY-2);
                     moveto(posX+2, posY-2); lineto(posX+4, posY-2);
                     moveto(posX-4, posY-1); lineto(posX-4, posY+1);
                     moveto(posX-3, posY-1); lineto(posX-3, posY+1);
                     moveto(posX+3, posY-1); lineto(posX+3, posY+1);
                     moveto(posX+4, posY-1); lineto(posX+4, posY+1);
                     moveto(posX-4, posY+2); lineto(posX-2, posY+2);
                     moveto(posX+2, posY+2); lineto(posX+4, posY+2);
                     moveto(posX-3, posY+3); lineto(posX+3, posY+3);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
 
                     break;
 
             case 8:
                     moveto(posX-4, posY-4); lineto(posX+4, posY-4);
                     moveto(posX-4, posY-3); lineto(posX+4, posY-3);
                     moveto(posX-4, posY-2); lineto(posX-4, posY+2);
                     moveto(posX-3, posY-2); lineto(posX-3, posY+2);
                     moveto(posX+3, posY-2); lineto(posX+3, posY+2);
                     moveto(posX+4, posY-2); lineto(posX+4, posY+2);
                     moveto(posX-4, posY+3); lineto(posX+4, posY+3);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
 
                     break;
 
             case 9:
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     moveto(posX-4, posY+3); lineto(posX+4, posY+3);
                     moveto(posX-3, posY+1); lineto(posX-3, posY+2);
                     moveto(posX-2, posY-1); lineto(posX-2, posY+2);
                     moveto(posX-1, posY-3); lineto(posX-1, posY);
                     moveto(posX, posY-4); lineto(posX, posY-2);
                     moveto(posX+1, posY-3); lineto(posX+1, posY);
                     moveto(posX+2, posY-1); lineto(posX+2, posY+2);
                     moveto(posX+3, posY+1); lineto(posX+3, posY+2);
 
                     break;
 
             case 10:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     moveto(posX-3, posY-3); lineto(posX+3, posY-3);
                     moveto(posX-4, posY-2); lineto(posX+4, posY-2);
                     moveto(posX-4, posY-1); lineto(posX+4, posY-1);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-4, posY+1); lineto(posX+4, posY+1);
                     moveto(posX-4, posY+2); lineto(posX+4, posY+2);
                     moveto(posX-3, posY+3); lineto(posX+3, posY+3);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
 
                     break;
 
             case 11:
                    for (radar_i=0; radar_i<9; radar_i++)
                    {
                         moveto(posX-4, posY-4+radar_i); lineto(posX+4, posY-4+radar_i);
                    }

 
                     break;
 
             case 12:
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-1, posY-3); lineto(posX-1, posY+4);
                     moveto(posX+1, posY-3); lineto(posX+1, posY+4);
                     moveto(posX-2, posY-1); lineto(posX-2, posY+4);
                     moveto(posX+2, posY-1); lineto(posX+2, posY+4);
                     moveto(posX-3, posY+1); lineto(posX-3, posY+4);
                     moveto(posX+3, posY+1); lineto(posX+3, posY+4);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
 
                     break;
 
            case 13:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     putpixel(posX-3, posY-3); putpixel(posX+3, posY-3);
                     moveto(posX-4, posY-2); lineto(posX-4, posY+2);
                     moveto(posX+4, posY-2); lineto(posX+4, posY+2);
                     putpixel(posX-3, posY+3); putpixel(posX+3, posY+3);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-1, posY-1); lineto(posX+1, posY-1);
                     moveto(posX-1, posY); lineto(posX+1, posY);
                     moveto(posX-1, posY+1); lineto(posX+1, posY+1);
                     break;
 
            case 14:
                     moveto(posX-4, posY-4); lineto(posX+4, posY-4);
                     moveto(posX-4, posY-4); lineto(posX-4, posY+4);
                     moveto(posX+4, posY-4); lineto(posX+4, posY+4);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-1, posY-1); lineto(posX+1, posY-1);
                     moveto(posX-1, posY); lineto(posX+1, posY);
                     moveto(posX-1, posY+1); lineto(posX+1, posY+1);
                     break;
 
 
            case 15:
                     moveto(posX, posY-4); lineto(posX, posY);
                     moveto(posX-1, posY-3); lineto(posX-1, posY);
                     moveto(posX+1, posY-3); lineto(posX+1, posY);
                     moveto(posX-2, posY-1); lineto(posX-2, posY);
                     moveto(posX+2, posY-1); lineto(posX+2, posY);
                     putpixel(posX-3, posY+1); putpixel(posX+3, posY+1);
                     moveto(posX-3, posY+2); lineto(posX-2, posY+2);
                     moveto(posX+2, posY+2); lineto(posX+3, posY+2);
                     moveto(posX-4, posY+3); lineto(posX-1, posY+3);
                     moveto(posX+1, posY+3); lineto(posX+4, posY+3);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);

                     break;
 
            case 16:
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-1, posY-1); lineto(posX+1, posY-1);
                     moveto(posX-1, posY); lineto(posX+1, posY);
                     moveto(posX-1, posY+1); lineto(posX+1, posY+1);
                     break;
 
            case 17:
                     moveto(posX, posY-3); lineto(posX, posY+3);
                     moveto(posX-3, posY); lineto(posX+3, posY);
                     moveto(posX-1, posY-1); lineto(posX+1, posY-1);
                     moveto(posX-1, posY); lineto(posX+1, posY);
                     moveto(posX-1, posY+1); lineto(posX+1, posY+1);
                     moveto(posX-1, posY-4); lineto(posX+1, posY-4);
                     moveto(posX-1, posY+4); lineto(posX+1, posY+4);
                     moveto(posX-4, posY-1); lineto(posX-4, posY+1);
                     moveto(posX+4, posY-1); lineto(posX+4, posY+1);
                     break;
 
            case 18:
                     moveto(posX, posY-4); lineto(posX, posY-1);
                     putpixel(posX-1, posY-3); putpixel(posX+1, posY-3);
                     putpixel(posX-2, posY-2); putpixel(posX+2, posY-2);
                     moveto(posX-1, posY); lineto(posX+1, posY);
                     moveto(posX-1, posY+1); lineto(posX+1, posY+1);
                     putpixel(posX-2, posY+2); putpixel(posX+2, posY+2);
                     putpixel(posX-3, posY+3); putpixel(posX+3, posY+3);
                     moveto(posX-4, posY+2); lineto(posX-4, posY+3);
                     moveto(posX+4, posY+2); lineto(posX+4, posY+3);
                     moveto(posX-4, posY+4); lineto(posX-2, posY+4);
                     moveto(posX+2, posY+4); lineto(posX+4, posY+4);

                     break;
 
            case 19:
                     moveto(posX-4, posY-2); lineto(posX-4, posY+2);
                     moveto(posX+4, posY-2); lineto(posX+4, posY+2);
                     moveto(posX-3, posY-3); lineto(posX-3, posY+3);
                     moveto(posX+3, posY-3); lineto(posX+3, posY+3);
                     moveto(posX-2, posY-4); lineto(posX-2, posY-3);
                     moveto(posX-2, posY+3); lineto(posX-2, posY+4);
                     moveto(posX+2, posY-4); lineto(posX+2, posY-3);
                     moveto(posX+2, posY+3); lineto(posX+2, posY+4);
                     moveto(posX-2, posY); lineto(posX+2, posY);
                     putpixel(posX, posY-1); putpixel(posX, posY+1);
                     break;
 
            case 20:
                     moveto(posX-4, posY-4); lineto(posX-4, posY+4);
                     moveto(posX+4, posY-4); lineto(posX+4, posY+4);
                     moveto(posX-3, posY-4); lineto(posX-3, posY+4);
                     moveto(posX+3, posY-4); lineto(posX+3, posY+4);
                     putpixel(posX-2, posY-4); putpixel(posX-2, posY+4);
                     putpixel(posX+2, posY-4); putpixel(posX+2, posY+4);
                     moveto(posX-2, posY); lineto(posX+2, posY);
                     putpixel(posX, posY-1); putpixel(posX, posY+1);
                     break;
 
            case 21:
                     putpixel(posX, posY-4);
                     moveto(posX-1, posY-3); lineto(posX+1, posY-3);
                     moveto(posX-1, posY-2); lineto(posX+1, posY-2);
                     moveto(posX-2, posY-1); lineto(posX+2, posY-1);
 
                     putpixel(posX-3, posY+1); putpixel(posX+3, posY+1);
                     moveto(posX-3, posY+2); lineto(posX-2, posY+2);
                     moveto(posX+2, posY+2); lineto(posX+3, posY+2);
 
                     moveto(posX-4, posY+3); lineto(posX-2, posY+3);
                     moveto(posX+2, posY+3); lineto(posX+4, posY+3);
                     moveto(posX-4, posY+4); lineto(posX-1, posY+4);
                     moveto(posX+1, posY+4); lineto(posX+4, posY+4);
                     break;
 
            case 22:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     moveto(posX-4, posY-2); lineto(posX+4, posY-2);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-4, posY+2); lineto(posX+4, posY+2);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
                     break;
 
            case 23:
                     moveto(posX-4, posY-4); lineto(posX+4, posY-4);
                     moveto(posX-4, posY-2); lineto(posX+4, posY-2);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-4, posY+2); lineto(posX+4, posY+2);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     break;

            case 24:
                     putpixel(posX, posY-4);
                     moveto(posX-1, posY-2); lineto(posX+1, posY-2);
                     moveto(posX-2, posY); lineto(posX+2, posY);
                     moveto(posX-3, posY+2); lineto(posX+3, posY+2);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     break;
 
            case 25:
                     moveto(posX-4, posY-2); lineto(posX-4, posY+2);
                     moveto(posX-2, posY-4); lineto(posX-2, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX+2, posY-4); lineto(posX+2, posY+4);
                     moveto(posX+4, posY-2); lineto(posX+4, posY+2);
                     break;
 
            case 26:
                     moveto(posX-4, posY-4); lineto(posX-4, posY+4);
                     moveto(posX-2, posY-4); lineto(posX-2, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX+2, posY-4); lineto(posX+2, posY+4);
                     moveto(posX+4, posY-4); lineto(posX+4, posY+4);
                     break;
 
            case 27:
                     moveto(posX-4, posY+3); lineto(posX-4, posY+4);
                     moveto(posX-2, posY-1); lineto(posX-2, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX+2, posY-1); lineto(posX+2, posY+4);
                     moveto(posX+4, posY+3); lineto(posX+4, posY+4);
                     break;
 
            case 28:
                     moveto(posX-2, posY-4); lineto(posX+2, posY-4);
                     moveto(posX-4, posY-2); lineto(posX+4, posY-2);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-4, posY+2); lineto(posX+4, posY+2);
                     moveto(posX-2, posY+4); lineto(posX+2, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-1, posY-2); lineto(posX-1, posY+4);
                     moveto(posX+1, posY-2); lineto(posX+1, posY+4);
                     moveto(posX-2, posY-2); lineto(posX-2, posY+4);
                     moveto(posX+2, posY-2); lineto(posX+2, posY+4);
                     break;
 
            case 29:
                     moveto(posX-4, posY-4); lineto(posX+4, posY-4);
                     moveto(posX-4, posY-2); lineto(posX+4, posY-2);
                     moveto(posX-4, posY); lineto(posX+4, posY);
                     moveto(posX-4, posY+2); lineto(posX+4, posY+2);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-1, posY-2); lineto(posX-1, posY+4);
                     moveto(posX+1, posY-2); lineto(posX+1, posY+4);
                     moveto(posX-2, posY-2); lineto(posX-2, posY+4);
                     moveto(posX+2, posY-2); lineto(posX+2, posY+4);
                     break;

            case 30:
                     putpixel(posX, posY-4);
                     moveto(posX-1, posY-2); lineto(posX+1, posY-2);
                     moveto(posX-2, posY); lineto(posX+2, posY);
                     moveto(posX-3, posY+2); lineto(posX+3, posY+2);
                     moveto(posX-4, posY+4); lineto(posX+4, posY+4);
                     moveto(posX, posY-4); lineto(posX, posY+4);
                     moveto(posX-1, posY-2); lineto(posX-1, posY+4);
                     moveto(posX+1, posY-2); lineto(posX+1, posY+4);
                     moveto(posX-2, posY-2); lineto(posX-2, posY+4);
                     moveto(posX+2, posY-2); lineto(posX+2, posY+4);
                     break;
           default:
                      //
                      break;
        }
    }
 
    setpen(ColorParts[4], ColorParts[5], ColorParts[6], ColorParts[7]/255.0, 1);
    for (radar_i=0; radar_i<borderSize; radar_i++)
    {
        moveto (radar_i, radar_i);
        lineto(radarWidth+(2*borderSize-radar_i), radar_i);
        lineto(radarWidth+(2*borderSize-radar_i), radarHeight+(2*borderSize-radar_i));
        lineto(radar_i, radarHeight+(2*borderSize-radar_i));
        lineto(radar_i, radar_i);
    }
}


DEMO BUILDING INSTRUCTIONS

Demo resources provide as .zip above but instructions comming soon (getting late, out of time)...
Last edited by GEuser on Wed Apr 03, 2013 11:44 pm, edited 3 times in total.
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score

Re: GEuser's CGUI Lib: radar() - create a radar system

Postby moonforge » Sat Mar 02, 2013 5:50 pm

This is REALLY nice. I am impressed by this concept. I was wondering if you could have the radar work as you moved the view around, like a multiplayer game. Speaking of that, there aren't too many uses for this, being that gE isn't wireless yet. The only thing that I am thinking of for this is showing you where enemies are. And still, the enemies are already in plain view. Try to make this work for things outside of view, and move with the view. Those would make this more impressive.
Don't get me wrong, though, I'm impressed.

~moonforge
http://wannowandrichardsgames.weebly.com/

"You don't have to win to be a winner. You just have to pretend to be better than everyone else."

+ 1 please?
User avatar
moonforge
 
Posts: 45
Joined: Mon Jan 28, 2013 3:58 am
Location: CENSORED
Score: 8 Give a positive score

Re: GEuser's CGUI Lib: radar() - create a radar system

Postby GEuser » Tue Mar 05, 2013 7:36 pm

moonforge wrote:This is REALLY nice. I am impressed by this concept. I was wondering if you could have the radar work as you moved the view around, like a multiplayer game. Speaking of that, there aren't too many uses for this, being that gE isn't wireless yet. The only thing that I am thinking of for this is showing you where enemies are. And still, the enemies are already in plain view. Try to make this work for things outside of view, and move with the view. Those would make this more impressive.
Don't get me wrong, though, I'm impressed.

~moonforge

Hi moonforge. It already allows you to see outside of the view. It's a function so you have to tell it what zoom level you want (you'd make the radar Scale higher for zoom out and lower for zoom in). By allowing you to tweak all the various parts during the function call it becomes much more useful and flexible.

A quick explanation of how ot use the radar scale would be...say your view (game window) is 640 x 480 and radar is 64 x 48. If you make the radar scale 1 then there is a 1 : 1 association with pixels on the screen and the radar window. It will clip out most of the current view (not what you'd ideally want unless you want an extreme zoom in.

Set radar scale to 10 instead of 1:-
View width / radar width = 640 / 64 =10. This means you need radar scale of 10 to see all the view window since now every radar pxel is worth 10 of view. If you set the radar scale to 20, it's like seeing double what you could with 10 and you end up seeing more (outside of view). The important part is that you make note of the size of your view window and the radar window and do a quick calc (View width / radar width) then use multiples of this for zooming in/out.

Examples (remember width & height ratio should remain the same).
If view size (320 x 240) & Radar size (64 x 48) then 320 / 64 = 5 so radar scale = 5 (normal view) & radar scale =10 (double view)
If view size (640 x 480 ) & Radarsize (128 x 96) then 640 / 128 = 5 so radar scale = 5 (normal view) & radar scale =10 (double view)
If view size (640 x 480 ) & Radar size ( 80 x 60 ) then 640 / 80 = 8 so radar scale = 8 (normal view) & radar scale =16 (double view)

Hope tthis help, Sorry for delay in reply been busy with 3D stuff for forum prroject, will provide more detaied reply with some updates to function later on.
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score

Re: GEuser's CGUI Lib: radar() - create a radar system

Postby GEuser » Sat Mar 30, 2013 10:59 pm

Sorry guy's. I know I promised I would do a quick demo. I was just doing some unrelated research stuff and wil be posting an updated version of the function with the ability to have a central actor (for displaying player, ship or cross-hair) and a way to choose between showing symbols for the radar targets or the target actor images. Working on it...
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score

Re: GEuser's CGUI Lib: radar() - create a radar system

Postby GEuser » Wed Apr 03, 2013 11:15 pm

Function completely overhauled. See 'Update Information' in first post for specifics.

Will add demo creation instructions later (getting late out of time for today)...
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score

Re: GEuser's CGUI Lib: radar() - create a radar system

Postby GEuser » Sun Apr 21, 2013 6:26 pm

Oops! I've been a bad boy, I totally forgot about this and haven't done the follow up tutorial :lol:
It will have to be put on my things to do list because right now I've been seduced by other stuff going on.
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score


Return to Game Resources

Who is online

Users browsing this forum: No registered users and 1 guest

cron