Tests out some new things
This commit is contained in:
parent
b88f3c0ef4
commit
6a21332877
@ -25,7 +25,7 @@ Dette prosjektet inneholder [Semesteroppgave 1](SEM-1.md). Du kan også [lese op
|
|||||||
* Levert av: *Kristian Knarvik* (*kkn015*)
|
* Levert av: *Kristian Knarvik* (*kkn015*)
|
||||||
* Del A: [x] helt ferdig, [ ] delvis ferdig
|
* Del A: [x] helt ferdig, [ ] delvis ferdig
|
||||||
* Del B: [ ] helt ferdig, [x] delvis ferdig
|
* Del B: [ ] helt ferdig, [x] delvis ferdig
|
||||||
* Del C: [ ] helt ferdig, [ ] delvis ferdig
|
* Del C: [ ] helt ferdig, [X] delvis ferdig
|
||||||
* [ ] hele semesteroppgaven er ferdig og klar til retting!
|
* [ ] hele semesteroppgaven er ferdig og klar til retting!
|
||||||
|
|
||||||
# Del A
|
# Del A
|
||||||
@ -79,7 +79,7 @@ d)
|
|||||||
* Main og Game har blitt endret til å tillate spilleren å selv velge når den har utført en tur. Dette har blitt gjort for å kunne ignorere uønskede tastetrykk, og for å tilby spilleren valg.
|
* Main og Game har blitt endret til å tillate spilleren å selv velge når den har utført en tur. Dette har blitt gjort for å kunne ignorere uønskede tastetrykk, og for å tilby spilleren valg.
|
||||||
|
|
||||||
### Tredjepartsfiler
|
### Tredjepartsfiler
|
||||||
* Bow Fire Arrow Sound fra http://soundbible.com av Stephan Schutze
|
* Bow Fire Arrow Sound (http://soundbible.com, Stephan Schutze, Noncommercial 3.0)
|
||||||
* Sword Swing Sound fra http://soundbible.com av Mike Koenig
|
* Sword Swing Sound (http://soundbible.com, Mike Koenig, Attribution 3.0)
|
||||||
* Large Fireball Sound fra http://soundbible.com av Mike Koenig
|
* Large Fireball Sound (http://soundbible.com av Mike Koenig, Attribution 3.0)
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ public class Screen {
|
|||||||
private final Canvas background;
|
private final Canvas background;
|
||||||
private final Group root;
|
private final Group root;
|
||||||
//private Paint bgColor = Color.CORNFLOWERBLUE;
|
//private Paint bgColor = Color.CORNFLOWERBLUE;
|
||||||
private Paint bgColor = Color.BROWN;
|
private Paint bgColor = Color.BLACK;
|
||||||
private int aspect = 0;
|
private int aspect = 0;
|
||||||
private double scaling = 0;
|
private double scaling = 0;
|
||||||
private double currentScale = 1.0;
|
private double currentScale = 1.0;
|
||||||
|
BIN
src/inf101/v18/gfx/fonts/Symbola.odt
Normal file
BIN
src/inf101/v18/gfx/fonts/Symbola.odt
Normal file
Binary file not shown.
BIN
src/inf101/v18/gfx/fonts/Symbola.pdf
Normal file
BIN
src/inf101/v18/gfx/fonts/Symbola.pdf
Normal file
Binary file not shown.
BIN
src/inf101/v18/gfx/fonts/Symbola.ttf
Normal file
BIN
src/inf101/v18/gfx/fonts/Symbola.ttf
Normal file
Binary file not shown.
BIN
src/inf101/v18/gfx/fonts/hintedSymbola.ttf
Normal file
BIN
src/inf101/v18/gfx/fonts/hintedSymbola.ttf
Normal file
Binary file not shown.
@ -75,7 +75,7 @@ public class Printer implements IPaintLayer {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color DEFAULT_FILL = Color.BLACK;
|
Color DEFAULT_FILL = Color.WHITE;
|
||||||
|
|
||||||
Color DEFAULT_STROKE = Color.TRANSPARENT;
|
Color DEFAULT_STROKE = Color.TRANSPARENT;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class Printer implements IPaintLayer {
|
|||||||
// private int pageWidth = LINE_WIDTHS[resMode], pageHeight =
|
// private int pageWidth = LINE_WIDTHS[resMode], pageHeight =
|
||||||
// PAGE_HEIGHTS[resMode];
|
// PAGE_HEIGHTS[resMode];
|
||||||
private int leftMargin = 1, topMargin = 1;
|
private int leftMargin = 1, topMargin = 1;
|
||||||
private TextFont font = FONT_LMMONO;
|
private TextFont font = FONT_SYMBOLA;
|
||||||
private int videoAttrs = 0;
|
private int videoAttrs = 0;
|
||||||
|
|
||||||
private String csiSeq = null;
|
private String csiSeq = null;
|
||||||
|
@ -229,7 +229,7 @@ public class Girl implements INonPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrintSymbol() {
|
public String getPrintSymbol() {
|
||||||
return "𓀠";
|
return "\u001b[95m" + "\uD83D\uDEB6" + "\u001b[0m";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,11 +19,8 @@ import inf101.v18.grid.ILocation;
|
|||||||
import inf101.v18.rogue101.Main;
|
import inf101.v18.rogue101.Main;
|
||||||
import inf101.v18.rogue101.enemies.Girl;
|
import inf101.v18.rogue101.enemies.Girl;
|
||||||
import inf101.v18.rogue101.examples.Carrot;
|
import inf101.v18.rogue101.examples.Carrot;
|
||||||
import inf101.v18.rogue101.items.IBuffItem;
|
import inf101.v18.rogue101.items.*;
|
||||||
import inf101.v18.rogue101.items.IWeapon;
|
|
||||||
import inf101.v18.rogue101.items.Manga;
|
|
||||||
import inf101.v18.rogue101.examples.Rabbit;
|
import inf101.v18.rogue101.examples.Rabbit;
|
||||||
import inf101.v18.rogue101.items.Sword;
|
|
||||||
import inf101.v18.rogue101.map.GameMap;
|
import inf101.v18.rogue101.map.GameMap;
|
||||||
import inf101.v18.rogue101.map.IGameMap;
|
import inf101.v18.rogue101.map.IGameMap;
|
||||||
import inf101.v18.rogue101.map.IMapView;
|
import inf101.v18.rogue101.map.IMapView;
|
||||||
@ -91,6 +88,11 @@ public class Game implements IGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prints some helpful information.
|
||||||
|
String[] info = {"Controls:", "WASD or arrow keys for movement", "E to pick up an item", "Q to drop an item", "1-5 to choose an item", "N to change name", "ENTER to confirm", "R to use a ranged attack", "F to use a magic attack"};
|
||||||
|
for (int i = 0; i < info.length; i++) {
|
||||||
|
this.printer.printAt(map.getWidth() + 2, 1 + i, info[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(String mapString) {
|
public Game(String mapString) {
|
||||||
@ -339,6 +341,7 @@ public class Game implements IGame {
|
|||||||
itemFactories.put("G", Girl::new);
|
itemFactories.put("G", Girl::new);
|
||||||
itemFactories.put(".", Dust::new);
|
itemFactories.put(".", Dust::new);
|
||||||
itemFactories.put("S", Sword::new);
|
itemFactories.put("S", Sword::new);
|
||||||
|
itemFactories.put("c", Chest::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
62
src/inf101/v18/rogue101/items/Chest.java
Normal file
62
src/inf101/v18/rogue101/items/Chest.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package inf101.v18.rogue101.items;
|
||||||
|
|
||||||
|
import inf101.v18.rogue101.game.IGame;
|
||||||
|
import inf101.v18.rogue101.objects.IItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Chest implements IContainer {
|
||||||
|
@Override
|
||||||
|
public IItem get(int i) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getContent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFull() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCurrentHealth() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDefence() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHealth() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrintSymbol() {
|
||||||
|
return "\uD83D\uDDC3";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSymbol() {
|
||||||
|
return "C";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int handleDamage(IGame game, IItem source, int amount) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package inf101.v18.rogue101.items;
|
package inf101.v18.rogue101.items;
|
||||||
|
|
||||||
import inf101.v18.rogue101.objects.IItem;
|
import inf101.v18.rogue101.objects.IItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +31,4 @@ public interface IContainer<T extends IItem> extends IItem {
|
|||||||
* @return True if it has no space left
|
* @return True if it has no space left
|
||||||
*/
|
*/
|
||||||
boolean isFull();
|
boolean isFull();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,13 @@ public class Manga implements IItem {
|
|||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrintSymbol() {
|
||||||
|
return "🕮";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSymbol() {
|
public String getSymbol() {
|
||||||
//return "🕮";
|
|
||||||
return "M";
|
return "M";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
50 20
|
40 20
|
||||||
##################################################
|
########################################
|
||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
# G G #
|
# G G #
|
||||||
# #
|
# #
|
||||||
############### # #
|
############### # #
|
||||||
# # #
|
# # #
|
||||||
# S # #
|
# S # #
|
||||||
# @ ####################### #
|
# @ ######## #########
|
||||||
# # #
|
# # #
|
||||||
# # #
|
# # #
|
||||||
# # #
|
# # #
|
||||||
# G #
|
# G #
|
||||||
# G #
|
# G #
|
||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
# G #
|
# G #
|
||||||
##################################################
|
########################################
|
@ -81,12 +81,21 @@ public class Player implements IPlayer {
|
|||||||
return turnConsumed;
|
return turnConsumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lets the user write his/her name.
|
||||||
|
*
|
||||||
|
* @param game An IGame object
|
||||||
|
* @param key The key pressed
|
||||||
|
*/
|
||||||
private void write(IGame game, KeyCode key) {
|
private void write(IGame game, KeyCode key) {
|
||||||
if (key != KeyCode.ENTER) {
|
if (key == KeyCode.BACK_SPACE) {
|
||||||
text += key.getName();
|
text = text.substring(0, text.length() - 1);
|
||||||
|
game.displayMessage("Please enter your name: " + text);
|
||||||
|
} else if (key != KeyCode.ENTER) {
|
||||||
|
text += key.toString();
|
||||||
game.displayMessage("Please enter your name: " + text);
|
game.displayMessage("Please enter your name: " + text);
|
||||||
} else {
|
} else {
|
||||||
name = text;
|
name = text.toLowerCase();
|
||||||
text = "";
|
text = "";
|
||||||
game.displayMessage("Name set.");
|
game.displayMessage("Name set.");
|
||||||
writing = false;
|
writing = false;
|
||||||
@ -102,7 +111,7 @@ public class Player implements IPlayer {
|
|||||||
private boolean pickUpInit(IGame game) {
|
private boolean pickUpInit(IGame game) {
|
||||||
List<IItem> items = game.getLocalItems();
|
List<IItem> items = game.getLocalItems();
|
||||||
if (items.size() < 1) {
|
if (items.size() < 1) {
|
||||||
game.displayMessage("There is nothing to pick up.");
|
game.displayMessage("There is nothing to pick up");
|
||||||
} else {
|
} else {
|
||||||
if (items.size() == 1) {
|
if (items.size() == 1) {
|
||||||
pickUp(game, 0);
|
pickUp(game, 0);
|
||||||
@ -129,6 +138,8 @@ public class Player implements IPlayer {
|
|||||||
if (equipped.size() == 1) {
|
if (equipped.size() == 1) {
|
||||||
drop(game, 0);
|
drop(game, 0);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (equipped.size() < 1) {
|
||||||
|
game.displayMessage("You have nothing to drop");
|
||||||
} else {
|
} else {
|
||||||
StringBuilder msg = new StringBuilder("Items to drop:");
|
StringBuilder msg = new StringBuilder("Items to drop:");
|
||||||
for (int i = 0; i < equipped.size(); i++) {
|
for (int i = 0; i < equipped.size(); i++) {
|
||||||
@ -195,7 +206,8 @@ public class Player implements IPlayer {
|
|||||||
String name = item.getName();
|
String name = item.getName();
|
||||||
items.add(firstCharToUpper(name));
|
items.add(firstCharToUpper(name));
|
||||||
}
|
}
|
||||||
game.formatStatus("HP: %d/%d ATK: %d DEF: %s INV: %s", hp, getMaxHealth(), getAttack(), getDefence(), String.join(",", items));
|
//TODO: Add item bonuses to visible stats.
|
||||||
|
game.formatStatus("HP: %d/%d ATK: %d DEF: %s DMG: %s INV: %s", hp, getMaxHealth(), getAttack(), getDefence(), getDamage(), String.join(",", items));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,7 +217,11 @@ public class Player implements IPlayer {
|
|||||||
* @return The input string with the first character uppercased
|
* @return The input string with the first character uppercased
|
||||||
*/
|
*/
|
||||||
private String firstCharToUpper(String input) {
|
private String firstCharToUpper(String input) {
|
||||||
return Character.toUpperCase(input.charAt(0)) + input.substring(1);
|
if (input.length() < 1) {
|
||||||
|
return input;
|
||||||
|
} else {
|
||||||
|
return Character.toUpperCase(input.charAt(0)) + input.substring(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryToMove(IGame game, GridDirection dir) {
|
private void tryToMove(IGame game, GridDirection dir) {
|
||||||
@ -257,7 +273,7 @@ public class Player implements IPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return firstCharToUpper(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -265,6 +281,11 @@ public class Player implements IPlayer {
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrintSymbol() {
|
||||||
|
return "\u001b[96m" + "@" + "\u001b[0m";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSymbol() {
|
public String getSymbol() {
|
||||||
return "@";
|
return "@";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user