Skip to content

Commit

Permalink
chore(Screen.java) add the show on/off map option
Browse files Browse the repository at this point in the history
  • Loading branch information
ololx committed Feb 3, 2021
1 parent 78210d5 commit 30b8634
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Refactor old project classes via game dev patterns implementation.

## [0.4.3-alpha] - 2021-02-03

### Added

- The map show on/off button - "M".

### Changed

- Make a static function for fog effect and implement it into scene like yellow fog.

## [0.4.2-alpha] - 2021-02-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Plain Old Retro Shooter is a 2.5D FPS game engine based on the raycasting technology.

[![status](https://img.shields.io/badge/status-active-active?style=flat-square)](BADGES_GUIDE.md#status) [![version](https://img.shields.io/badge/version-0.4.2--alpha-informational?style=flat-square)](BADGES_GUIDE.md#version) [![stable](https://img.shields.io/badge/stable-no-important?style=flat-square)](BADGES_GUIDE.md#stable) [![build](https://img.shields.io/badge/build-passing-success?style=flat-square)](BADGES_GUIDE.md#build) [![oss lifecycle](https://img.shields.io/badge/oss_lifecycle-active-important?style=flat-square)](BADGES_GUIDE.md#oss-lifecycle) [![maintenance](https://img.shields.io/badge/maintenance-yes-informational?style=flat-square)](BADGES_GUIDE.md#maintenance) [![latest release date](https://img.shields.io/badge/latest_release_date-February_01,_2021-informational?style=flat-square)](BADGES_GUIDE.md#release-date) [![last commit](https://img.shields.io/badge/last_commit-February_01,_2021-informational?style=flat-square)](BADGES_GUIDE.md#commit-date)
[![status](https://img.shields.io/badge/status-active-active?style=flat-square)](BADGES_GUIDE.md#status) [![version](https://img.shields.io/badge/version-0.4.3--alpha-informational?style=flat-square)](BADGES_GUIDE.md#version) [![stable](https://img.shields.io/badge/stable-no-important?style=flat-square)](BADGES_GUIDE.md#stable) [![build](https://img.shields.io/badge/build-passing-success?style=flat-square)](BADGES_GUIDE.md#build) [![oss lifecycle](https://img.shields.io/badge/oss_lifecycle-active-important?style=flat-square)](BADGES_GUIDE.md#oss-lifecycle) [![maintenance](https://img.shields.io/badge/maintenance-yes-informational?style=flat-square)](BADGES_GUIDE.md#maintenance) [![latest release date](https://img.shields.io/badge/latest_release_date-February_03,_2021-informational?style=flat-square)](BADGES_GUIDE.md#release-date) [![last commit](https://img.shields.io/badge/last_commit-February_03,_2021-informational?style=flat-square)](BADGES_GUIDE.md#commit-date)

[![license](https://img.shields.io/badge/license-MIT-informational?style=flat-square)](LICENSE) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](CODE_OF_CONDUCT.md)

Expand Down
11 changes: 7 additions & 4 deletions src/org/plain/old/retro/shooter/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public class Scene extends JFrame {
/**
* The constant SCENE_WIDTH.
*/
public static final int SCENE_WIDTH = 640;//2560;
public static final int SCENE_WIDTH = 1366;

/**
* The constant SCENE_HEIGHT.
*/
public static final int SCENE_HEIGHT = 480;//1440;
public static final int SCENE_HEIGHT = 768;

/**
* The constant SCENE_WIDTH.
Expand Down Expand Up @@ -230,6 +230,7 @@ public Scene(Client client) {
put(KeyEvent.VK_DOWN, "MV_DOWN");
put(KeyEvent.VK_SPACE, "SHOT");
put(KeyEvent.VK_R, "RELOAD");
put(KeyEvent.VK_M, "MAP");
}},
center
);
Expand All @@ -245,8 +246,6 @@ public Scene(Client client) {
addMouseListener(controller);
addMouseMotionListener(controllerMouseMove);

System.out.println(center);

this.sceneTemp = new LowIntensiveClock(
30,
() -> {
Expand Down Expand Up @@ -305,6 +304,10 @@ public Scene(Client client) {
if (state.getKey().equals("ESC")) {
controllerMouseMove.swtch();
}

if (state.getKey().equals("MAP")) {
screen.switchShowMap();
}
}
}
},
Expand Down
8 changes: 7 additions & 1 deletion src/org/plain/old/retro/shooter/engine/graphics/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
public class Screen {

private boolean showMap = false;

/**
* The type Ray.
*/
Expand Down Expand Up @@ -201,6 +203,10 @@ public Screen(int[][] map, int width, int height, List<Sprite> textures, Camera
this.rayCast(playerCamera);
}

public void switchShowMap() {
this.showMap ^= true;
}

public int[] renderFloor(int[] pixels, Camera playerCamera) {
return this.drawHorizontalSurface(
pixels,
Expand Down Expand Up @@ -600,7 +606,7 @@ public int[] render(int[] pixels,
}}
);
pixels = this.renderGun(pixels, gun.getSprite());
pixels = this.renderMap(pixels, playerCamera);
if (this.showMap) pixels = this.renderMap(pixels, playerCamera);

return pixels;
}
Expand Down

0 comments on commit 30b8634

Please sign in to comment.