Onscreen minimap

Version:

1.0

Added on:

13 Nov 2021 16: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
  1. int i = 0;
  2. int j = 0;
  3. int cooldown = 0;
  4. int shift_x = (jjResolutionWidth/2) - (jjLayerWidth[4]/2);
  5. int shift_y = (jjResolutionHeight/2) - (jjLayerHeight[4]/2);
  6. bool show_map = false;
  7.  
  8. void onPlayerInput(jjPLAYER@ player) {
  9.   if (p.keySelect && cooldown==0){
  10.     if (!show_map) show_map = true;
  11.     else  show_map = false;
  12.     cooldown = 15;
  13.     }
  14.   if (cooldown > 0) cooldown--;
  15. }
  16.  
  17. bool onDrawScore(jjPLAYER@ player, jjCANVAS@ screen) {
  18.  
  19. if (show_map){
  20. for (i = 0; i < jjLayerWidth[4]; i++){ for (j = 0; j < jjLayerHeight[4]; j++){
  21.   if (jjMaskedPixel((i*32)+16, (j*32)+16))
  22.     screen.drawPixel(i+shift_x, j+shift_y, 122, SPRITE::NORMAL,  0);
  23.   else screen.drawPixel(i+shift_x, j+shift_y, 120, SPRITE::TRANSLUCENTCOLOR,  0);}}
  24. for (i = -1; i < 2; i++){ for (j = -1; j < 2; j++){
  25.   screen.drawPixel((p.xPos/32)+shift_x+i, (p.yPos/32)+shift_y+j, jjSin(jjGameTicks)*128, SPRITE::NORMAL,  0);}}
  26. }
  27.  
  28. return false;
  29. }