Mario minigame easter egg

This commit is contained in:
Andrea Cavalli 2018-04-01 01:01:57 +02:00
parent b788bedc48
commit 270b698c59
13 changed files with 703 additions and 118 deletions

View File

@ -31,6 +31,7 @@ public class Keyboard {
private static volatile boolean[][] precedentStates = new boolean[8][8];
public static volatile boolean[][] debugKeysDown = new boolean[8][8];
public static volatile int debugKeyCode = -1;
public static volatile int debugKeyCodeRelease = -1;
private static volatile boolean refreshRequest = false;
@ -45,6 +46,10 @@ public class Keyboard {
debugKeyPressed(debugKeyCode);
debugKeyCode = -1;
}
if (debugKeyCodeRelease != -1) {
debugKeyReleased(debugKeyCodeRelease);
debugKeyCodeRelease = -1;
}
Thread.sleep(50);
}
} catch (final InterruptedException e) {}
@ -438,6 +443,51 @@ public class Keyboard {
}
}
private synchronized static void debugKeyReleased(int keyCode) {
switch (keyCode) {
case KeyEvent.VK_ENTER:
int row = 2;
int col = 1;
Keyboard.debugKeysDown[row - 1][col - 1] = false;
break;
case com.jogamp.newt.event.KeyEvent.VK_LEFT:
case KeyEvent.VK_LEFT:
//LEFT
row = 2;
col = 3;
Keyboard.debugKeysDown[row - 1][col - 1] = false;
break;
case com.jogamp.newt.event.KeyEvent.VK_RIGHT:
case KeyEvent.VK_RIGHT:
//RIGHT
row = 2;
col = 5;
Keyboard.debugKeysDown[row - 1][col - 1] = false;
System.out.println("RELEASE");
break;
case com.jogamp.newt.event.KeyEvent.VK_UP:
case KeyEvent.VK_UP:
//UP
row = 1;
col = 4;
Keyboard.debugKeysDown[row - 1][col - 1] = false;
break;
case com.jogamp.newt.event.KeyEvent.VK_DOWN:
case KeyEvent.VK_DOWN:
//DOWN
row = 3;
col = 4;
Keyboard.debugKeysDown[row - 1][col - 1] = false;
break;
case (short) 12:
//DOWN
row = 2;
col = 4;
Keyboard.debugKeysDown[row - 1][col - 1] = false;
break;
}
}
public static boolean isKeyDown(int row, int col) {
if (StaticVars.debugOn == false) {
return precedentStates[row - 1][col - 1];
@ -482,8 +532,8 @@ public class Keyboard {
{Key.NONE, Key.NONE, Key.NONE}, /* 2,2 */
{Key.DOWN, Key.NONE, Key.NONE}, /* 2,3 */
{Key.BACK, Key.NONE, Key.NONE}, /* 2,4 */
{Key.NONE, Key.NONE, Key.NONE}, /* 2,5 */
{Key.NONE, Key.NONE, Key.NONE}, /* 2,6 */
{Key.HISTORY_BACK, Key.NONE, Key.NONE}, /* 2,5 */
{Key.HISTORY_FORWARD, Key.NONE, Key.NONE}, /* 2,6 */
{Key.NONE, Key.NONE, Key.LETTER_Z} /* 2,7 */
},
{ /* ROW 3 */
@ -604,7 +654,7 @@ public class Keyboard {
refresh = true;
break;
case ZOOM_MODE:
StaticVars.windowZoom = ((StaticVars.windowZoom - 1) % 2) + 2;
StaticVars.windowZoom = (StaticVars.windowZoom % 3) + 1;
// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
refresh = true;
case HISTORY_BACK:

View File

@ -0,0 +1,28 @@
package org.warp.picalculator.extra.mario;
public class MarioBlock {
private int x, y;
private byte id;
public MarioBlock(int x, int y, byte b) {
this.x = x;
this.y = y;
id = b;
}
public boolean isSolid() {
return id != 0b0;
}
public byte getID() {
return id;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}

View File

@ -0,0 +1,9 @@
package org.warp.picalculator.extra.mario;
public class MarioEnemy extends MarioEntity {
public MarioEnemy(double x, double y, double forceX, double forceY, boolean onGround, boolean subjectToGravity) {
super(x, y, forceX, forceY, onGround, subjectToGravity);
}
}

View File

@ -0,0 +1,85 @@
package org.warp.picalculator.extra.mario;
public class MarioEntity {
protected double x;
protected double y;
public double forceX;
public double forceY;
public boolean collisionUp;
public boolean collisionDown;
public boolean collisionLeft;
public boolean collisionRight;
public boolean subjectToGravity;
public MarioEntity(double x, double y, double forceX, double forceY, boolean onGround, boolean subjectToGravity) {
this.x = x;
this.y = y;
this.forceX = forceX;
this.forceY = forceY;
this.collisionDown = onGround;
this.subjectToGravity = subjectToGravity;
}
public void setPosition(double x, double y) {
this.x = x;
this.y = y;
}
public void setPosition(double x, double y, boolean onGround) {
this.x = x;
this.y = y;
this.collisionDown = onGround;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public boolean isOnGround() {
return collisionDown;
}
public void setOnGround(boolean onGround) {
this.collisionDown = onGround;
}
public void gameTick(double dt) {
this.x = computeFutureDX(dt);
this.y = computeFutureDY(dt);
this.forceX = computeFutureForceDX(dt);
this.forceY = computeFutureForceDY(dt);
}
public double computeFutureDX(double dt) {
return (x + dt * forceX) - this.x;
}
public double computeFutureDY(double dt) {
double forceY = this.forceY;
double y = this.y;
if (!collisionDown) {
y += dt * forceY;
}
return y - this.y;
}
public double computeFutureForceDX(double dt) {
double forceX = this.forceX;
forceX *= 0.75;
return forceX - this.forceX;
}
public double computeFutureForceDY(double dt) {
double forceY = this.forceY;
if (subjectToGravity && !this.collisionDown) {
forceY -= dt * 1569.6/16f;
} else {
forceY *= 0.75;
}
return forceY - this.forceY;
}
}

View File

@ -0,0 +1,5 @@
package org.warp.picalculator.extra.mario;
public class MarioEvent {
}

View File

@ -0,0 +1,264 @@
package org.warp.picalculator.extra.mario;
public class MarioGame {
private PlayerEntity player;
private int currentWorld;
private MarioWorld[] worlds;
private boolean canMove;
public MarioGame() {
player = new PlayerEntity(1, 0, 5);
currentWorld = 0;
worlds = new MarioWorld[] {new MarioWorld(new int[] {1, 6}, 100, 20, new byte[] {
0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 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b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0b0, 0
}, new MarioEvent[] {
}, new MarioEntity[] {
})};
playAgain();
}
private void playAgain() {
canMove = false;
MarioWorld w = getCurrentWorld();
w.reset();
player.setPosition(w.getSpawnPointX(), w.getSpawnPointY(), true);
canMove = true;
}
public MarioBlock getBlockAt(int x, int y) {
return worlds[currentWorld].getBlockAt(x, y);
}
public MarioBlock getBlockAt(double x, double y) {
return getBlockAt((int)x, (int)y);
}
public void move(float dt, double deltaX, double deltaY) {
double curX = player.getX();
double curY = player.getY();
double futureX = curX + deltaX;
double futureY = curY + deltaY;
boolean forward = futureX >= curX;
boolean up = futureY >= curY;
player.move(dt, futureX - curX, futureY - curY);
}
public MarioWorld getCurrentWorld() {
return worlds[currentWorld];
}
public void gameTick(float dt, boolean upPressed, boolean downPressed, boolean leftPressed, boolean rightPressed, boolean jumpPressed, boolean runPressed) {
checkOnGround(getPlayer(), dt);
checkCollisionTop(getPlayer(), dt);
checkCollisionLeft(getPlayer(), dt);
checkCollisionRight(getPlayer(), dt);
if (canMove) {
move(dt, (rightPressed ? 1 : 0) - (leftPressed ? 1 : 0), jumpPressed ? 1 : 0);
}
getPlayer().gameTick(dt);
MarioWorld w = getCurrentWorld();
for (MarioEntity e : w.getEntities()) {
checkOnGround(e, dt);
checkCollisionTop(e, dt);
checkCollisionLeft(e, dt);
checkCollisionRight(e, dt);
e.gameTick(dt);
}
}
private int nearest(double val, int a, int b) {
double aa = Math.abs(val - a);
double ab = Math.abs(val - b);
if (aa < ab) {
return (int) aa;
} else {
return (int) ab;
}
}
private void checkOnGround(MarioEntity e, float dt) {
if (e.subjectToGravity) {
int xA = (int) Math.floor(e.getX());
int xB = (int) Math.ceil(e.getX());
int y0 = (int) Math.ceil(e.getY());
int y1 = (int) Math.ceil(e.getY() + e.computeFutureDY(dt));
if (y1 < y0) {
for (int y = y0; y >= y1; y--) {
for (int x = xA; x <= xB; x++) {
MarioBlock b = getCurrentWorld().getBlockAt((int)x, y-1);
if (b.isSolid()) {
if (e.forceY < 0) {
e.setOnGround(true);
e.forceY = 0;
e.setPosition(e.getX(), (int)b.getY() + 1, true);
}
break;
} else {
e.setOnGround(false);
}
}
}
} else {
for (int x = xA; x <= xB; x++) {
MarioBlock b = getCurrentWorld().getBlockAt((int)x, (int)y0-1);
if (b.isSolid()) {
if (e.forceY < 0) {
e.setOnGround(true);
e.forceY = 0;
e.setPosition(e.getX(), (int)b.getY() + 1, true);
}
} else {
e.setOnGround(false);
}
}
}
}
}
private void checkCollisionTop(MarioEntity e, float dt) {
if (e.subjectToGravity) {
int xA = (int) Math.floor(e.getX());
int xB = (int) Math.ceil(e.getX());
int y0 = (int) Math.floor(e.getY());
int y1 = (int) Math.floor(e.getY() + e.computeFutureDY(dt));
if (y1 > y0) {
for (int y = (int) y0; y <= y1; y++) {
for (int x = xA; x <= xB; x++) {
MarioBlock b = getCurrentWorld().getBlockAt((int)x, y+1);
if (b.isSolid()) {
if (e.forceY > 0) {
e.forceY = 0;
e.setPosition(e.getX(), (int)b.getY() - 1);
e.collisionUp = true;
}
break;
} else {
e.collisionUp = false;
}
}
}
} else {
for (int x = xA; x <= xB; x++) {
MarioBlock b = getCurrentWorld().getBlockAt((int)x, (int)y0+1);
if (b.isSolid()) {
if (e.forceY > 0) {
e.forceY = 0;
e.setPosition(e.getX(), (int)b.getY() - 1);
e.collisionUp = true;
}
} else {
e.collisionUp = false;
}
}
}
}
}
private void checkCollisionRight(MarioEntity e, float dt) {
if (e.subjectToGravity) {
int yA = (int) Math.floor(e.getY());
int yB = (int) Math.ceil(e.getY());
int x0 = (int) Math.floor(e.getX());
double x1double = e.getX() + e.computeFutureDX(dt);
int x1 = (int) Math.floor(x1double);
if (x1 > x0) {
for (int x = (int) x0; x <= x1; x++) {
for (int y = yA; y <= yB; y++) {
MarioBlock b = getCurrentWorld().getBlockAt(x+1, (int)y);
if (b.isSolid()) {
if (e.forceX > 0 && x1double >= b.getX() - 1) {
e.forceX = 0;
e.setPosition(b.getX() - 1, e.getY());
e.collisionRight = true;
}
break;
} else {
e.collisionRight = false;
}
}
}
} else {
for (int y = yA; y <= yB; y++) {
MarioBlock b = getCurrentWorld().getBlockAt((int)x0+1, (int)y);
if (b.isSolid()) {
if (e.forceX > 0 && x1double >= b.getX() - 1) {
e.forceX = 0;
e.setPosition(b.getX() - 1, e.getY());
e.collisionRight = true;
}
} else {
e.collisionRight = false;
}
}
}
}
}
private void checkCollisionLeft(MarioEntity e, float dt) {
if (e.subjectToGravity) {
int yA = (int) Math.floor(e.getY());
int yB = (int) Math.ceil(e.getY());
int x0 = (int) Math.ceil(e.getX());
double x1double = e.getX() + e.computeFutureDX(dt);
int x1 = (int) Math.ceil(x1double);
if (x1 < x0) {
for (int x = (int) x0; x >= x1; x--) {
for (int y = yA; y <= yB; y++) {
MarioBlock b = getCurrentWorld().getBlockAt(x-1, (int)y);
if (b.isSolid()) {
if (e.forceX < 0 && x1double <= b.getX()+1) {
e.forceX = 0;
e.setPosition(b.getX()+1, e.getY());
e.collisionLeft = true;
}
break;
} else {
e.collisionLeft = false;
}
}
}
} else {
for (int y = yA; y <= yB; y++) {
MarioBlock b = getCurrentWorld().getBlockAt((int)x0-1, (int)y);
if (b.isSolid()) {
if (e.forceX < 0 && x1double <= b.getX()+1) {
e.forceX = 0;
e.setPosition(b.getX()+1, e.getY());
e.collisionLeft = true;
}
} else {
e.collisionLeft = false;
}
}
}
}
}
public PlayerEntity getPlayer() {
return player;
}
}

View File

@ -0,0 +1,62 @@
package org.warp.picalculator.extra.mario;
public class MarioWorld {
private int[] spawnPoint;
private int width;
private int height;
private byte[] data;
private MarioEvent[] events;
private MarioEntity[] entities;
/**
* @param width
* @param height
* @param data
* @param events
* @param marioEnemies
*/
public MarioWorld(int[] spawnPoint, int width, int height, byte[] data, MarioEvent[] events, MarioEntity[] entities) {
this.spawnPoint = spawnPoint;
this.width = width;
this.height = height;
this.data = data;
this.events = events;
this.entities = entities;
}
public byte getBlockIdAt(int x, int y) {
int idx = (height - 1 - y) * width + x;
if (idx < 0 || idx >= data.length) return 0b0;
return data[idx];
}
public MarioBlock getBlockAt(int x, int y) {
return new MarioBlock(x, y, getBlockIdAt(x, y));
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void reset() {
}
public double getSpawnPointX() {
return spawnPoint[0];
}
public double getSpawnPointY() {
return spawnPoint[1];
}
public MarioEntity[] getEntities() {
return entities;
}
}

View File

@ -0,0 +1,136 @@
package org.warp.picalculator.extra.mario;
public class PlayerEntity extends MarioEntity {
private int life;
public float walkAnimation = 0;
public float jumptime = 0;
public boolean walking = false;
public boolean running = false;
public boolean jumping = false;
public boolean flipped = false;
public int[] marioSkinPos = new int[] { 0, 0 };
private double controllerDX;
private double controllerDY;
public PlayerEntity(double x, double y, int life) {
super(x, y, 0, 0, true, true);
this.life = life;
}
@Override
public void gameTick(double dt) {
walkAnimation += dt;
this.x += computeFutureDX(dt);
this.y += computeFutureDY(dt);
this.forceX += computeFutureForceDX(dt);
this.forceY += computeFutureForceDY(dt);
if (controllerDX == 0) {
walking = false;
walkAnimation = 0;
} else {
if (controllerDX > 0) { //RIGHT
walking = true;
flipped = false;
}
if (controllerDX < 0) { //LEFT
walking = true;
flipped = true;
}
}
if (controllerDY > 0) { //JUMP
if (collisionUp) {
jumptime = Float.MAX_VALUE;
jumping = false;
}
jumptime += dt;
if (jumptime <= 0.5f && !jumping && collisionDown) {
jumping = true;
collisionDown = false;
} else if (jumptime <= 0.5f) {
} else {
jumping = false;
}
} else {
jumping = false;
if (collisionDown) {
jumptime = 0;
} else {
jumptime = Float.MAX_VALUE;
}
}
if (!walking & !running & !jumping) {
marioSkinPos[0] = 0;
marioSkinPos[1] = 0;
} else if (collisionDown & walking & !running & !jumping && walkAnimation >= 0.08) {
while (walkAnimation > 0.08) {
walkAnimation -= 0.08;
if (marioSkinPos[0] == 1 & marioSkinPos[1] == 0) {
marioSkinPos[0] += 2;
} else if (marioSkinPos[0] == 3 & marioSkinPos[1] == 0) {
marioSkinPos[0] -= 1;
} else if (marioSkinPos[0] == 2 & marioSkinPos[1] == 0) {
marioSkinPos[0] -= 1;
} else {
marioSkinPos[0] = 1;
marioSkinPos[1] = 0;
}
}
} else if (jumping) {
marioSkinPos[0] = 5;
marioSkinPos[1] = 1;
}
}
public double computeFutureDX(double dt) {
return super.computeFutureDX(dt);
}
public double computeFuturedDY(double dt) {
return super.computeFutureDY(dt);
}
public double computeFutureForceDX(double dt) {
double forceX = this.forceX;
if (controllerDX == 0) {
} else {
if (controllerDX > 0) { //RIGHT
if (forceX < 500f/16f) {
forceX += dt * 500f/16f;
}
}
if (controllerDX < 0) { //LEFT
if (forceX > -500f/16f) {
forceX -= dt * 500f/16f;
}
}
}
return (forceX + super.computeFutureForceDX(dt)) - this.forceX;
}
public double computeFutureForceDY(double dt) {
float jumptime = this.jumptime;
double forceY = this.forceY;
if (controllerDY > 0) { //JUMP
if (collisionUp) {
jumptime = Float.MAX_VALUE;
}
jumptime += dt;
if (jumptime <= 0.5f && !jumping && collisionDown) {
forceY = dt * (4 * 1569.6f)/16f;
} else if (jumptime <= 0.5f) {
forceY = dt * (4 * 1569.6f)/16f;
}
}
return (forceY + super.computeFutureForceDY(dt)) - this.forceY;
}
public void move(float dt, double dX, double dY) {
walkAnimation += dt;
this.controllerDX = dX;
this.controllerDY = dY;
}
}

View File

@ -0,0 +1,5 @@
package org.warp.picalculator.extra.mario;
public class PositionEvent extends MarioEvent {
}

View File

@ -48,7 +48,8 @@ public class CPURenderer implements Renderer {
public void glClear(int screenWidth, int screenHeight) {
for (int x = 0; x < screenWidth; x++) {
for (int y = 0; y < screenHeight; y++) {
canvas2d[x + y * size[0]] = clearcolor;
int index = x + y * size[0];
if (index >= 0 && index < canvas2d.length) canvas2d[index] = clearcolor;
}
}
}
@ -108,9 +109,11 @@ public class CPURenderer implements Renderer {
pixelX = (x0 + texx * onex + width);
pixelY = (y0 + texy * oney + height);
if (pixelX - (pixelX % size[0]) == 0) {
final int index = pixelX + pixelY * size[0];
if (canvas2d.length > index) {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
if (transparent) {
oldColor = canvas2d[pixelX + pixelY * size[0]];
oldColor = canvas2d[index];
final float a2 = (newColor >> 24 & 0xFF) / 255f;
final float a1 = 1f - a2;
final int r = (int) ((oldColor >> 16 & 0xFF) * a1 + (newColor >> 16 & 0xFF) * a2);
@ -118,7 +121,8 @@ public class CPURenderer implements Renderer {
final int b = (int) ((oldColor & 0xFF) * a1 + (newColor & 0xFF) * a2);
newColor = 0xFF000000 | r << 16 | g << 8 | b;
}
canvas2d[pixelX + pixelY * size[0]] = newColor;
canvas2d[index] = newColor;
}
}
}
}

View File

@ -87,7 +87,7 @@ public class SwingWindow extends JFrame {
@Override
public void keyReleased(KeyEvent arg0) {
Keyboard.debugKeyCodeRelease = arg0.getKeyCode();
}
@Override

View File

@ -5,12 +5,17 @@ import java.io.IOException;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.extra.mario.MarioBlock;
import org.warp.picalculator.extra.mario.MarioGame;
import org.warp.picalculator.extra.mario.MarioWorld;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.Skin;
public class MarioScreen extends Screen {
private MarioGame g;
private static Skin skin;
private static Skin groundskin;
private static BinaryFont easterfont;
@ -23,16 +28,14 @@ public class MarioScreen extends Screen {
private int easterFu32Num = 0;
private float easterFu32Elapsed = 0;
private boolean errored;
public float[] marioPos = new float[] { 30, 0 };
public float[] marioForces = new float[] { 0, 0 };
public float walkAnimation = 0;
public float jumptime = 0;
public boolean walking = false;
public boolean running = false;
public boolean jumping = false;
public boolean flipped = false;
public boolean onGround = true;
public int[] marioSkinPos = new int[] { 0, 0 };
// public float[] marioPos = new float[] { 30, 0 };
// public float[] marioForces = new float[] { 0, 0 };
// public float jumptime = 0;
// public boolean walking = false;
// public boolean running = false;
// public boolean jumping = false;
// public boolean flipped = false;
// public boolean onGround = true;
public MarioScreen() {
super();
@ -66,76 +69,18 @@ public class MarioScreen extends Screen {
@Override
public void created() throws InterruptedException {
if (!errored) {
g = new MarioGame();
}
}
@Override
public void beforeRender(float dt) {
if (!errored) {
walkAnimation += dt;
final boolean rightPressed = Keyboard.isKeyDown(2, 5);
final boolean leftPressed = Keyboard.isKeyDown(2, 3);
final boolean jumpPressed = Keyboard.isKeyDown(2, 1);
if ((leftPressed || rightPressed) == (leftPressed & rightPressed)) {
walking = false;
walkAnimation = 0;
} else {
if (rightPressed) { //RIGHT
if (marioForces[0] < 500f) {
marioForces[0] += dt * 500f;
}
walking = true;
flipped = false;
}
if (leftPressed) { //LEFT
if (marioForces[0] > -500f) {
marioForces[0] -= dt * 500f;
}
walking = true;
flipped = true;
}
}
if (jumpPressed) { //JUMP
jumptime += dt;
if (!jumping && onGround) {
marioForces[1] = dt * (4 * 1569.6f);
jumping = true;
onGround = false;
} else if (jumptime <= 0.5f) {
marioForces[1] = dt * (4 * 1569.6f);
}
} else {
jumping = false;
jumptime = 0;
}
if (!walking & !running & !jumping) {
marioSkinPos[0] = 0;
marioSkinPos[1] = 0;
} else if (onGround & walking & !running & !jumping && walkAnimation >= 0.08) {
while (walkAnimation > 0.08) {
walkAnimation -= 0.08;
if (marioSkinPos[0] == 1 & marioSkinPos[1] == 0) {
marioSkinPos[0] += 2;
} else if (marioSkinPos[0] == 3 & marioSkinPos[1] == 0) {
marioSkinPos[0] -= 1;
} else if (marioSkinPos[0] == 2 & marioSkinPos[1] == 0) {
marioSkinPos[0] -= 1;
} else {
marioSkinPos[0] = 1;
marioSkinPos[1] = 0;
}
}
} else if (jumping) {
marioSkinPos[0] = 5;
marioSkinPos[1] = 1;
}
marioForces[1] -= dt * 1569.6;
marioPos[0] += dt * marioForces[0];
if (!onGround) {
marioPos[1] -= dt * marioForces[1];
}
marioForces[0] *= 0.75;
final boolean upPressed = false, downPressed = false, runPressed = false;
g.gameTick(dt, upPressed, downPressed, leftPressed, rightPressed, jumpPressed, runPressed);
easterElapsed += dt;
while (easterElapsed >= 0.04) {
@ -157,26 +102,31 @@ public class MarioScreen extends Screen {
if (errored) {
DisplayManager.INSTANCE.renderer.glDrawStringLeft(0, 20, "ERROR");
} else {
if (groundskin != null) {
groundskin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 0, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 1, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 2, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 3, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 4, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 5, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 6, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 7, 25 + 25, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 8, 25 + 25, 16, 16, 0, 0, 16, 16);
MarioWorld w = g.getCurrentWorld();
int width = w.getWidth();
int height = w.getHeight();
for (int ix = 0; ix < width; ix++) {
for (int iy = 0; iy < height; iy++) {
MarioBlock b = w.getBlockAt(ix, iy);
if (b.getID() != 0) {
DisplayManager.INSTANCE.renderer.glFillRect(16 * ix, 16 * (height - iy), 16, 16, 0, 0, 16, 16);
}
}
}
DisplayManager.INSTANCE.renderer.glFillRect(16 * 0, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 1, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 2, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 3, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 4, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 5, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 6, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 7, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
DisplayManager.INSTANCE.renderer.glFillRect(16 * 8, 25 + 25 + 16 * 1, 16, 16, 0, 0, 16, 16);
//DRAW MARIO
DisplayManager.INSTANCE.renderer.glFillRect(16 * (float)g.getPlayer().getX(), 16 * (height - (float)g.getPlayer().getY()),
16, 16,
0, 0, 16, 16);
skin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glFillRect(-8 + 16 * (float)g.getPlayer().getX() + (g.getPlayer().flipped ? -4 : 0), -8 + 16 * (height - (float)g.getPlayer().getY()),
35, 27,
35 * (g.getPlayer().marioSkinPos[0] + (g.getPlayer().flipped ? 2 : 1)), 27 * g.getPlayer().marioSkinPos[1],
35 * (g.getPlayer().flipped ? -1 : 1), 27);
// PIDisplay.renderer.glDrawSkin(getPosX() - 18, 25 + getPosY(), 35 * (marioSkinPos[0] + (flipped ? 2 : 1)), 27 * marioSkinPos[1], 35 * (marioSkinPos[0] + (flipped ? 1 : 2)), 27 * (marioSkinPos[1] + 1), true);
}
// EASTER EGG
if (fu32font != null) {
@ -208,11 +158,6 @@ public class MarioScreen extends Screen {
DisplayManager.INSTANCE.renderer.glColor(0xFFffede7);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "G");
}
//DRAW MARIO
skin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glFillRect(getPosX() - 18, 25 + getPosY(), 35, 27, 35 * (marioSkinPos[0] + 1), 27 * marioSkinPos[1], 35, 27);
// PIDisplay.renderer.glDrawSkin(getPosX() - 18, 25 + getPosY(), 35 * (marioSkinPos[0] + (flipped ? 2 : 1)), 27 * marioSkinPos[1], 35 * (marioSkinPos[0] + (flipped ? 1 : 2)), 27 * (marioSkinPos[1] + 1), true);
}
}
@ -231,12 +176,4 @@ public class MarioScreen extends Screen {
return false;
}
private int getPosX() {
return (int) marioPos[0];
}
private int getPosY() {
return (int) marioPos[1];
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 36 KiB