Skip to content

Commit

Permalink
v1.8.1 - Backend Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
redomar committed Oct 27, 2014
2 parents ac0efd0 + 6c5ac01 commit 39a34d4
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 127 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JavaGame Alpha v1.8
JavaGame Alpha v1.8.1
===================

#####What is JavaGame?
Expand Down Expand Up @@ -34,7 +34,4 @@ Watch this video [here](http://youtu.be/_3nCgac3KKM) or checkout the [GitHub Pag
* Make the changes in the /src folder
* Commit your changes (```git commit -m "Change Title"```)
* Push to the branch (```git push origin my_branch```)
* Open a [Pull Request](https://github.com/redomar/JavaGame/pull/new/master)

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/redomar/javagame/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![Ohloh Stats](https://www.ohloh.net/p/JavaGame/widgets/project_thin_badge.gif)](https://www.ohloh.net/p/JavaGame)
* Open a [Pull Request](https://github.com/redomar/JavaGame/pull/new/master)
Binary file modified jar/javagame.jar
Binary file not shown.
103 changes: 53 additions & 50 deletions src/com/redomar/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.redomar.game.lib.Font;
import com.redomar.game.lib.Music;
import com.redomar.game.lib.Time;
import com.redomar.game.menu.Menu;
import com.redomar.game.net.GameClient;
import com.redomar.game.net.GameServer;
import com.redomar.game.net.packets.Packet00Login;
Expand All @@ -36,7 +35,7 @@ public class Game extends Canvas implements Runnable {

// Setting the size and name of the frame/canvas
private static final long serialVersionUID = 1L;
private static final String game_Version = "v1.8 Alpha";
private static final String game_Version = "v1.8.1 Alpha";
private static final int WIDTH = 160;
private static final int HEIGHT = (WIDTH / 3 * 2);
private static final int SCALE = 3;
Expand All @@ -57,7 +56,7 @@ public class Game extends Canvas implements Runnable {
private static int steps;
private static boolean devMode;
private static boolean closingMode;

private static JFrame frame;

private static boolean running = false;
Expand Down Expand Up @@ -90,10 +89,10 @@ public class Game extends Canvas implements Runnable {
private GameServer socketServer;
private Printing print = new Printing();
private static InputContext context;

/**
* @author Redomar
* @version Alpha 1.8
* @version Alpha 1.8.1
*/
public Game() {
context = InputContext.getInstance();
Expand Down Expand Up @@ -143,33 +142,34 @@ public void init() {

// socketClient.sendData("ping".getBytes());
loginPacket.writeData(getSocketClient());
game.setVendor(new Vendor(getLevel(), "Vendor", 215, 215, 304, 543));
getLevel().addEntity(getVendor());

game.setVendor(new Vendor(level, "Vendor", 215, 215, 304, 543));
level.addEntity(getVendor());
}

public void setMap(String Map_str) {
setLevel(new LevelHandler(Map_str));
if(alternateCols[0]){
if (alternateCols[0]) {
Game.setShirtCol(240);
}
if(!alternateCols[0]){
if (!alternateCols[0]) {
Game.setShirtCol(111);
}
if(alternateCols[1]){
if (alternateCols[1]) {
Game.setFaceCol(310);
}
if(!alternateCols[1]){
if (!alternateCols[1]) {
Game.setFaceCol(543);
}
setPlayer(new PlayerMP(getLevel(), 100, 100, input,
setPlayer(new PlayerMP(level, 100, 100, input,
getJdata_UserName(), null, -1, shirtCol, faceCol));
level.addEntity(player);
}

public static void npcSpawn() {
if (isNpc() == true) {
game.setDummy(new Dummy(Game.getLevel(), "Dummy", 100, 150, 500, 543));
game.setDummy(new Dummy(game.level, "Dummy", 100, 150, 500,
543));
game.level.addEntity(Game.getDummy());
}
}
Expand Down Expand Up @@ -235,7 +235,10 @@ public void run() {

if (System.currentTimeMillis() - lastTimer >= 1000) {
lastTimer += 1000;
getFrame().setTitle("JavaGame - Version "+WordUtils.capitalize(game_Version).substring(1, game_Version.length()));
getFrame().setTitle(
"JavaGame - Version "
+ WordUtils.capitalize(game_Version).substring(
1, game_Version.length()));
fps = frames;
tps = ticks;
frames = 0;
Expand All @@ -247,7 +250,7 @@ public void run() {

public void tick() {
setTickCount(getTickCount() + 1);
getLevel().tick();
level.tick();
}

public void render() {
Expand All @@ -260,7 +263,7 @@ public void render() {
int xOffset = (int) getPlayer().getX() - (screen.getWidth() / 2);
int yOffset = (int) getPlayer().getY() - (screen.getHeight() / 2);

getLevel().renderTiles(screen, xOffset, yOffset);
level.renderTiles(screen, xOffset, yOffset);

/*
* for (int x = 0; x < level.width; x++) { int colour = Colours.get(-1,
Expand All @@ -269,8 +272,8 @@ public void render() {
* colour, 1); }
*/

getLevel().renderEntities(screen);
getLevel().renderProjectileEntities(screen);
level.renderEntities(screen);
level.renderProjectileEntities(screen);

for (int y = 0; y < screen.getHeight(); y++) {
for (int x = 0; x < screen.getWidth(); x++) {
Expand Down Expand Up @@ -306,19 +309,18 @@ public void render() {
print.print("Teleported into new world", PrintTypes.GAME);
if (getMap() == 1) {
setMap("/levels/water_level.png");
if(getDummy()!=null){ // Gave nullPointerException(); upon entering new world.
getLevel().removeEntity(getDummy());
if (getDummy() != null) { // Gave nullPointerException(); upon
// entering new world.
level.removeEntity(getDummy());
setNpc(false);
}
getLevel().removeEntity(getVendor());
level.removeEntity(getVendor());
setMap(2);
} else if (getMap() == 2) {
setMap("/levels/custom_level.png");
if(getDummy()!=null){
getLevel().removeEntity(getDummy());
setNpc(false);
}
getLevel().addEntity(getVendor());
level.removeEntity(getDummy());
setNpc(false);
level.addEntity(getVendor());
setMap(1);
}
changeLevel = false;
Expand All @@ -337,14 +339,14 @@ public void render() {
+ WordUtils.capitalizeFully(player
.getSantizedUsername()), 3, getHeight() - 17);
g.setColor(Color.ORANGE);
if(context.getLocale().getCountry().equals("BE") || context.getLocale().getCountry().equals("FR"))
{
g.drawString("Press A to quit", (getWidth()/2)-("Press A to quit".length()*3), getHeight() -17);
}
else
{
g.drawString("Press Q to quit", (getWidth()/2)-("Press Q to quit".length()*3), getHeight() -17);

if (context.getLocale().getCountry().equals("BE")
|| context.getLocale().getCountry().equals("FR")) {
g.drawString("Press A to quit", (getWidth() / 2)
- ("Press A to quit".length() * 3), getHeight() - 17);
} else {
g.drawString("Press Q to quit", (getWidth() / 2)
- ("Press Q to quit".length() * 3), getHeight() - 17);
}
g.setColor(Color.YELLOW);
g.drawString(time.getTime(), (getWidth() - 58), (getHeight() - 3));
Expand Down Expand Up @@ -383,33 +385,34 @@ public void render() {
}

private void status(Graphics g, boolean TerminalMode, boolean TerminalQuit) {
if (TerminalMode == true){
if (TerminalMode == true) {
g.setColor(Color.CYAN);
g.drawString("JavaGame Stats", 0, 10);
g.drawString("FPS/TPS: " + fps + "/" + tps, 0, 25);
if ((player.getNumSteps() & 15) == 15) {
steps += 1;
}
g.drawString("Foot Steps: " + steps, 0, 40);
g.drawString("NPC: " + WordUtils.capitalize(String.valueOf(isNpc())) , 0, 55);
g.drawString("Mouse: " + getMouse().getX() + "x |" + getMouse().getY() + "y", 0, 70);
if(getMouse().getButton() != -1) g.drawString("Button: " + getMouse().getButton(), 0, 85);
g.drawString(
"NPC: " + WordUtils.capitalize(String.valueOf(isNpc())), 0,
55);
g.drawString("Mouse: " + getMouse().getX() + "x |"
+ getMouse().getY() + "y", 0, 70);
if (getMouse().getButton() != -1)
g.drawString("Button: " + getMouse().getButton(), 0, 85);
g.setColor(Color.CYAN);
g.fillRect(getMouse().getX()-12, getMouse().getY()-12, 24, 24);
g.fillRect(getMouse().getX() - 12, getMouse().getY() - 12, 24, 24);
}
if (TerminalQuit == true){
if (TerminalQuit == true) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.RED);
g.drawString("Shutting down the Game", (getWidth()/2)-70, (getHeight()/2)-8);
g.drawString("Shutting down the Game", (getWidth() / 2) - 70,
(getHeight() / 2) - 8);
g.dispose();
}
}

public static void main(String[] args) {
new Menu().start();
}

public static JFrame getFrame() {
return Game.frame;
}
Expand Down Expand Up @@ -581,12 +584,12 @@ public static boolean[] getAlternateCols() {
public static void setAlternateCols(boolean[] alternateCols) {
Game.alternateCols = alternateCols;
}
public static void setAternateColsR(boolean alternateCols){

public static void setAternateColsR(boolean alternateCols) {
Game.alternateCols[1] = alternateCols;
}
public static void setAternateColsS(boolean alternateCols){

public static void setAternateColsS(boolean alternateCols) {
Game.alternateCols[0] = alternateCols;
}

Expand Down
20 changes: 10 additions & 10 deletions src/com/redomar/game/InputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,35 @@ public void toggleKey(int keyCode, boolean isPressed) {
if (isIgnoreInput() == false) {
if (isAzertyCountry) {
if (keyCode == KeyEvent.VK_Z || keyCode == KeyEvent.VK_UP) {
getUp().toggle(isPressed);
up.toggle(isPressed);
}

if (keyCode == KeyEvent.VK_Q || keyCode == KeyEvent.VK_LEFT) {
getLeft().toggle(isPressed);
left.toggle(isPressed);
}
} else {
if (keyCode == KeyEvent.VK_W || keyCode == KeyEvent.VK_UP) {
getUp().toggle(isPressed);
up.toggle(isPressed);
}

if (keyCode == KeyEvent.VK_A || keyCode == KeyEvent.VK_LEFT) {
getLeft().toggle(isPressed);
left.toggle(isPressed);
}
}

if (keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_DOWN) {
getDown().toggle(isPressed);
down.toggle(isPressed);
}

if (keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_RIGHT) {
getRight().toggle(isPressed);
right.toggle(isPressed);
}
}
if (isIgnoreInput() == true) {
getUp().toggle(false);
getDown().toggle(false);
getLeft().toggle(false);
getRight().toggle(false);
up.toggle(false);
down.toggle(false);
left.toggle(false);
right.toggle(false);
}
if (keyCode == KeyEvent.VK_M) {
this.setPlayMusic(true);
Expand Down
11 changes: 11 additions & 0 deletions src/com/redomar/game/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.redomar.game;

import com.redomar.game.menu.Menu;

public class Launcher
{
public static void main(String[] args)
{
new Menu().start();
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions src/com/redomar/game/entities/Dummy.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void tick() {


setSwim(new Swim(level, (int) getX(), (int) getY()));
swimType = getSwim().swimming(isSwimming, isMagma, isMuddy);
swimType = swim.swimming(isSwimming, isMagma, isMuddy);
isSwimming = swimType[0];
isMagma = swimType[1];
isMuddy = swimType[2];
Expand Down Expand Up @@ -77,7 +77,7 @@ public void render(Screen screen) {
int yOffset = (int) getY() - modifier / 2 - 4;

if (isSwimming || isMagma || isMuddy) {
swimColour = getSwim().waveCols(isSwimming, isMagma, isMuddy);
swimColour = swim.waveCols(isSwimming, isMagma, isMuddy);

int waterColour = 0;
yOffset += 4;
Expand Down
4 changes: 2 additions & 2 deletions src/com/redomar/game/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void tick() {
}

setSwim(new Swim(level, (int) getX(), (int) getY()));
swimType = getSwim().swimming(isSwimming, isMagma, isMuddy);
swimType = swim.swimming(isSwimming, isMagma, isMuddy);
isSwimming = swimType[0];
isMagma = swimType[1];
isMuddy = swimType[2];
Expand Down Expand Up @@ -148,7 +148,7 @@ public void render(Screen screen) {
}

if(isSwimming || isMagma || isMuddy){
swimColour = getSwim().waveCols(isSwimming, isMagma, isMuddy);
swimColour = swim.waveCols(isSwimming, isMagma, isMuddy);

int waterColour = 0;
yOffset += 4;
Expand Down
6 changes: 3 additions & 3 deletions src/com/redomar/game/entities/Vendor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void tick() {
moveMob(xa, ya, this);

setSwim(new Swim(level, (int) getX(), (int) getY()));
swimType = getSwim().swimming(isSwimming, isMagma, isMuddy);
swimType = swim.swimming(isSwimming, isMagma, isMuddy);
isSwimming = swimType[0];
isMagma = swimType[1];
isMuddy = swimType[2];
Expand All @@ -54,7 +54,7 @@ public void tick() {
}

public void render(Screen screen) {
setTime(getTime() + 1);
setTime(time + 1);
int xTile = 8;
int yTile = 28;
int walkingSpeed = 4;
Expand All @@ -81,7 +81,7 @@ public void render(Screen screen) {
int yOffset = (int) getY() - modifier / 2 - 4;

if (isSwimming || isMagma || isMuddy) {
swimColour = getSwim().waveCols(isSwimming, isMagma, isMuddy);
swimColour = swim.waveCols(isSwimming, isMagma, isMuddy);

int waterColour = 0;
yOffset += 4;
Expand Down
2 changes: 1 addition & 1 deletion src/com/redomar/game/gfx/SpriteSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SpriteSheet(String path) {
this.setWidth(image.getWidth());
this.height = image.getHeight();

pixels = image.getRGB(0, 0, getWidth(), height, null, 0, getWidth());
pixels = image.getRGB(0, 0, width, height, null, 0, width);

for (int i = 0; i < pixels.length; i++) {
pixels[i] = (pixels[i] & 0xff) / 64; // removes alpha (transparency)
Expand Down
Loading

0 comments on commit 39a34d4

Please sign in to comment.