Onscreen minimap

Version:

1.0

Added on:

13 Nov 2021 15:37

Tags:

Description:
Togglable level map on the centre of the screen.
Press "change weapon" to show the map. FPS drops a bit when active
int i = 0;
int j = 0;
int cooldown = 0;
int shift_x = (jjResolutionWidth/2) - (jjLayerWidth[4]/2);
int shift_y = (jjResolutionHeight/2) - (jjLayerHeight[4]/2);
bool show_map = false;

void onPlayerInput(jjPLAYER@ player) {
  if (p.keySelect && cooldown==0){
    if (!show_map) show_map = true;
    else  show_map = false;
    cooldown = 15;
    }
  if (cooldown > 0) cooldown--;
}

bool onDrawScore(jjPLAYER@ player, jjCANVAS@ screen) {
  
if (show_map){
for (i = 0; i < jjLayerWidth[4]; i++){ for (j = 0; j < jjLayerHeight[4]; j++){
  if (jjMaskedPixel((i*32)+16, (j*32)+16)) 
    screen.drawPixel(i+shift_x, j+shift_y, 122, SPRITE::NORMAL,  0);
  else screen.drawPixel(i+shift_x, j+shift_y, 120, SPRITE::TRANSLUCENTCOLOR,  0);}}
for (i = -1; i < 2; i++){ for (j = -1; j < 2; j++){
  screen.drawPixel((p.xPos/32)+shift_x+i, (p.yPos/32)+shift_y+j, jjSin(jjGameTicks)*128, SPRITE::NORMAL,  0);}}
}

return false;
}