-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
336 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package fr.adamaq01.gravirush; | ||
|
||
import fr.adamaq01.suplge.api.Game; | ||
import fr.adamaq01.suplge.api.graphics.Color; | ||
import fr.adamaq01.suplge.api.graphics.IGraphics; | ||
import fr.adamaq01.suplge.opengl.graphics.shapes.Rectangle; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* Created by Adamaq01 on 22/04/2017. | ||
*/ | ||
public class Stage { | ||
|
||
private Random random; | ||
private boolean level[][]; | ||
|
||
private int doorX, doorY; | ||
|
||
public void init(Game game) { | ||
random = new Random(); | ||
level = new boolean[1000][1000]; | ||
|
||
for(int x = 0; x < 1000; x++) { | ||
for(int y = 0; y < 1000; y++) { | ||
boolean draw = random.nextInt(100) > 30; | ||
level[x][y] = !draw; | ||
} | ||
} | ||
|
||
generateDoor(game); | ||
|
||
} | ||
|
||
public void generateDoor(Game game) { | ||
int doorX = random.nextInt(game.getWindow().getWidth() / 24); | ||
int doorY = random.nextInt(game.getWindow().getWidth() / 24); | ||
|
||
if(level[doorX][doorY] && !level[doorX][doorY + (32 / 24)]) { | ||
this.doorX = doorX; | ||
this.doorY = doorY + (32 / 24); | ||
} else { | ||
generateDoor(game); | ||
} | ||
} | ||
|
||
public void update(Game game, int playerX, int playerY, double delta) { | ||
if(new Rectangle(16, 32).collides(playerX, playerY, doorX * 24, doorY * 24)) { | ||
GraviRush.getSocket().emit("changepixel"); | ||
game.setCurrentScreen(Screens.MAIN_MENU); | ||
} | ||
} | ||
|
||
public void drawStage(IGraphics graphics) { | ||
for(int x = 0; x < graphics.getWindow().getWidth() / 24; x++) { | ||
for (int y = 0; y < graphics.getWindow().getHeight() / 24; y++) { | ||
if(level[x][y]) { | ||
graphics.setColor(new Color(77, 51, 25)); | ||
graphics.fillShape(new Rectangle(32, 32), x * 24, y * 24); | ||
graphics.setColor(new Color(0, 153, 51)); | ||
graphics.fillShape(new Rectangle(32, 4), x * 24, y * 24 + 28); | ||
} | ||
} | ||
} | ||
graphics.drawShape(new Rectangle(16, 32), doorX * 24, doorY * 24); | ||
} | ||
|
||
public boolean collides(Game game, int x, int y) { | ||
for(int rectx = 0; rectx < game.getWindow().getWidth() / 24; rectx++) { | ||
for (int recty = 0; recty < game.getWindow().getHeight() / 24; recty++) { | ||
if(level[rectx][recty]) { | ||
new Rectangle(32, 32).collides(x, y, rectx * 24, recty * 24); | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
src/main/java/fr/adamaq01/gravirush/screens/InGame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package fr.adamaq01.gravirush.screens; | ||
|
||
import fr.adamaq01.gravirush.Stage; | ||
import fr.adamaq01.suplge.SuplgeEngine; | ||
import fr.adamaq01.suplge.api.Game; | ||
import fr.adamaq01.suplge.api.IImage; | ||
import fr.adamaq01.suplge.api.IScreen; | ||
import fr.adamaq01.suplge.api.graphics.Color; | ||
import fr.adamaq01.suplge.api.graphics.IGraphics; | ||
import fr.adamaq01.suplge.api.input.controllers.IController; | ||
import fr.adamaq01.suplge.api.input.keyboards.IKeyboard; | ||
import fr.adamaq01.suplge.input.ControllerManager; | ||
import fr.adamaq01.suplge.input.KeyboardManager; | ||
import fr.adamaq01.suplge.opengl.GLWindow; | ||
import fr.adamaq01.suplge.opengl.graphics.GLGraphics; | ||
import fr.adamaq01.suplge.opengl.graphics.shapes.Rectangle; | ||
import fr.adamaq01.suplge.opengl.utils.GLImage; | ||
|
||
/** | ||
* Created by Adamaq01 on 22/04/2017. | ||
*/ | ||
public class InGame implements IScreen<GLWindow, GLGraphics> { | ||
|
||
private int x, y; | ||
private long lastInput; | ||
|
||
// Animation | ||
private IImage tutter; | ||
private int index; | ||
private long lastAnimationChange; | ||
|
||
// Stage | ||
private Stage stage; | ||
private boolean inStage; | ||
|
||
@Override | ||
public void onEnable(Game<GLWindow> game) { | ||
this.stage = new Stage(); | ||
this.tutter = new GLImage(SuplgeEngine.getResource("tutter.png")); | ||
this.index = 0; | ||
this.lastAnimationChange = System.currentTimeMillis(); | ||
this.x = 0; | ||
this.y = 0; | ||
this.stage.init(game); | ||
this.inStage = false; | ||
} | ||
|
||
@Override | ||
public void onDisable(Game<GLWindow> game) { | ||
|
||
} | ||
|
||
@Override | ||
public void update(Game<GLWindow> game, double delta) { | ||
IController controller = ControllerManager.MANAGER.get(0); | ||
IKeyboard keyboard = KeyboardManager.MANAGER.get(0); | ||
|
||
if(inStage) { | ||
|
||
|
||
if (controller.getJoyStickValue(IController.JoyStick.JOY_STICK_1, IController.ControllerAxe.AXE_JOY_STICK_VERTICAL) < -0.3 || controller.isButtonPressed(IController.Button.BUTTON_CROSSPAD_DOWN) || keyboard.isKeyPressed(IKeyboard.Key.KEY_S)) | ||
y -= 1 * delta; | ||
if (controller.getJoyStickValue(IController.JoyStick.JOY_STICK_1, IController.ControllerAxe.AXE_JOY_STICK_VERTICAL) > 0.3 || controller.isButtonPressed(IController.Button.BUTTON_CROSSPAD_UP) || keyboard.isKeyPressed(IKeyboard.Key.KEY_Z)) | ||
y += 1 * delta; | ||
if (controller.getJoyStickValue(IController.JoyStick.JOY_STICK_1, IController.ControllerAxe.AXE_JOY_STICK_HORIZONTAL) < -0.3 || controller.isButtonPressed(IController.Button.BUTTON_CROSSPAD_LEFT) || keyboard.isKeyPressed(IKeyboard.Key.KEY_Q)) | ||
x -= 1 * delta; | ||
if (controller.getJoyStickValue(IController.JoyStick.JOY_STICK_1, IController.ControllerAxe.AXE_JOY_STICK_HORIZONTAL) > 0.3 || controller.isButtonPressed(IController.Button.BUTTON_CROSSPAD_RIGHT) || keyboard.isKeyPressed(IKeyboard.Key.KEY_D)) | ||
x += 1 * delta; | ||
|
||
|
||
stage.update(game, x, y, delta); | ||
if (System.currentTimeMillis() - this.lastAnimationChange > 83) { | ||
this.lastAnimationChange = System.currentTimeMillis(); | ||
if (this.index == 10) | ||
this.index = 0; | ||
else | ||
this.index++; | ||
} | ||
} else { | ||
if(System.currentTimeMillis() - lastInput > 1200) { | ||
lastInput = System.currentTimeMillis(); | ||
if (controller.isButtonPressed(IController.Button.BUTTON_ACTION_DOWN)) { | ||
this.stage = new Stage(); | ||
this.stage.init(game); | ||
}else if (controller.isButtonPressed(IController.Button.BUTTON_ACTION_RIGHT)) { | ||
inStage = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void render(Game<GLWindow> game, GLGraphics glGraphics) { | ||
if(inStage) { | ||
renderStage(game, glGraphics); | ||
} else { | ||
renderStageChooser(game, glGraphics); | ||
} | ||
} | ||
|
||
public void renderStage(Game game, IGraphics graphics) { | ||
stage.drawStage(graphics); | ||
graphics.drawImage(tutter.sub(0, 256 * index, 256, 256), x, y, 24, 24, false); | ||
} | ||
|
||
public void renderStageChooser(Game game, IGraphics graphics) { | ||
stage.drawStage(graphics); | ||
graphics.setColor(Color.SILVER); | ||
graphics.fillShape(new Rectangle(game.getWindow().getWidth(), game.getWindow().getHeight() / 40), 0, 0); | ||
graphics.fillShape(new Rectangle(game.getWindow().getWidth(), game.getWindow().getHeight() / 40), 0, game.getWindow().getHeight() - game.getWindow().getHeight() / 40); | ||
graphics.fillShape(new Rectangle(game.getWindow().getWidth() / 40, game.getWindow().getHeight()), 0, 0); | ||
graphics.fillShape(new Rectangle(game.getWindow().getWidth() / 40, game.getWindow().getHeight()), game.getWindow().getWidth() - game.getWindow().getWidth() / 40, 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package fr.adamaq01.gravirush.screens; | ||
|
||
import fr.adamaq01.gravirush.Screens; | ||
import fr.adamaq01.suplge.SuplgeEngine; | ||
import fr.adamaq01.suplge.api.Game; | ||
import fr.adamaq01.suplge.api.IImage; | ||
import fr.adamaq01.suplge.api.IScreen; | ||
import fr.adamaq01.suplge.api.graphics.Color; | ||
import fr.adamaq01.suplge.api.input.controllers.IController; | ||
import fr.adamaq01.suplge.input.ControllerManager; | ||
import fr.adamaq01.suplge.opengl.GLWindow; | ||
import fr.adamaq01.suplge.opengl.graphics.GLGraphics; | ||
import fr.adamaq01.suplge.opengl.utils.GLImage; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* Created by Adamaq01 on 22/04/2017. | ||
*/ | ||
public class Llaw implements IScreen<GLWindow, GLGraphics> { | ||
|
||
private IImage lellaw; | ||
|
||
@Override | ||
public void onEnable(Game<GLWindow> game) { | ||
this.lellaw = new GLImage(SuplgeEngine.getResourceWithoutBaseURL("https://lellaw.adamaq01.fr/")); | ||
} | ||
|
||
@Override | ||
public void onDisable(Game<GLWindow> game) { | ||
} | ||
|
||
@Override | ||
public void update(Game<GLWindow> game, double v) { | ||
IController controller = ControllerManager.MANAGER.get(0); | ||
if(controller.isButtonPressed(IController.Button.BUTTON_ACTION_DOWN)) { | ||
game.setCurrentScreen(Screens.MAIN_MENU); | ||
} | ||
} | ||
|
||
@Override | ||
public void render(Game<GLWindow> game, GLGraphics glGraphics) { | ||
glGraphics.drawImage(this.lellaw, 0, 0, game.getWindow().getWidth(), game.getWindow().getHeight(), false); | ||
} | ||
} |
Oops, something went wrong.