Megadex functionality implemented. Little details still have to be

added, but retrieving from the database is successful.
master
sigonasr2 7 years ago
parent 5322cb402d
commit 5338463bf5
  1. BIN
      Megamon-core/assets/Megamon/2.png
  2. BIN
      Megamon-core/assets/Megamon/2_back.png
  3. BIN
      Megamon-core/assets/Megamon/2_icon.png
  4. BIN
      Megamon-core/assets/Megamon/3.png
  5. BIN
      Megamon-core/assets/Megamon/3_back.png
  6. BIN
      Megamon-core/assets/Megamon/3_icon.png
  7. BIN
      Megamon-core/assets/Megamon/4.png
  8. BIN
      Megamon-core/assets/Megamon/4_back.png
  9. BIN
      Megamon-core/assets/Megamon/4_icon.png
  10. BIN
      Megamon-core/assets/Megamon/5.png
  11. BIN
      Megamon-core/assets/Megamon/5_back.png
  12. BIN
      Megamon-core/assets/Megamon/5_icon.png
  13. BIN
      Megamon-core/assets/Megamon/6.png
  14. BIN
      Megamon-core/assets/Megamon/6_back.png
  15. BIN
      Megamon-core/assets/Megamon/6_icon.png
  16. BIN
      Megamon-core/assets/interface/healthbar_horizontal.png
  17. BIN
      Megamon-core/assets/interface/megadex.png
  18. BIN
      Megamon-core/assets/interface/tiledbackground.png
  19. 2430
      Megamon-core/src/sig/megamon/Database.java
  20. 47
      Megamon-core/src/sig/megamon/Megamon.java
  21. 22
      Megamon-core/src/sig/megamon/MegamonCreature.java
  22. 24
      Megamon-core/src/sig/megamon/MegamonPet.java
  23. 11
      Megamon-core/src/sig/megamon/creature/CreatureMoveLinker.java
  24. 69
      Megamon-core/src/sig/megamon/menu/ColorCycler.java
  25. 49
      Megamon-core/src/sig/megamon/menu/FancyBackground.java
  26. 252
      Megamon-core/src/sig/megamon/menu/MegadexMenu.java
  27. 8
      Megamon-core/src/sig/megamon/menu/MegamonPartyScreen.java
  28. 3
      Megamon-core/src/sig/megamon/menu/StartMenuBox.java
  29. 16
      Megamon-core/src/sig/megamon/utils/DrawUtils.java

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

File diff suppressed because it is too large Load Diff

@ -36,6 +36,7 @@ import sig.megamon.creature.CreatureMoveLinker;
import sig.megamon.creature.CreatureType; import sig.megamon.creature.CreatureType;
import sig.megamon.creature.ExperienceRate; import sig.megamon.creature.ExperienceRate;
import sig.megamon.menu.DialogBox; import sig.megamon.menu.DialogBox;
import sig.megamon.menu.MegadexMenu;
import sig.megamon.menu.MegamonPartyScreen; import sig.megamon.menu.MegamonPartyScreen;
import sig.megamon.menu.StartMenuBox; import sig.megamon.menu.StartMenuBox;
import sig.megamon.ref.Ref; import sig.megamon.ref.Ref;
@ -52,7 +53,8 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
public static DialogBox messagebox; public static DialogBox messagebox;
public static StartMenuBox startmenubox; public static StartMenuBox startmenubox;
public static MegamonPartyScreen partyscreen; public static MegamonPartyScreen partyscreen;
public static Texture healthbar; public static MegadexMenu megadexscreen;
public static Texture healthbar,healthbar_horizontal;
//AssetManager assets; //AssetManager assets;
//TiledMap map; //TiledMap map;
static OrthographicCamera camera; static OrthographicCamera camera;
@ -71,12 +73,14 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
final public static int MOVEUPKEY = Keys.UP; final public static int MOVEUPKEY = Keys.UP;
final public static int MOVEDOWNKEY = Keys.DOWN; final public static int MOVEDOWNKEY = Keys.DOWN;
final public static int MENUKEY = Keys.ENTER; final public static int MENUKEY = Keys.ENTER;
public final static int CURSORDELAYTIMER = 5;
public static List<MegamonCreature> megamonDatabase = new ArrayList<MegamonCreature>(); public static List<MegamonCreature> megamonDatabase = new ArrayList<MegamonCreature>();
public static HashMap<String,CreatureMove> moveDatabase = new HashMap<String,CreatureMove>(); public static HashMap<String,CreatureMove> moveDatabase = new HashMap<String,CreatureMove>();
//public static List<Object> objects = new ArrayList<Object>(); //public static List<Object> objects = new ArrayList<Object>();
public static Room currentLevel; public static Room currentLevel;
public static HashMap<String,RoomRef> doorDatabase = new HashMap<String,RoomRef>(); public static HashMap<String,RoomRef> doorDatabase = new HashMap<String,RoomRef>();
public static HashMap<String,SignRef> infoDatabase = new HashMap<String,SignRef>(); public static HashMap<String,SignRef> infoDatabase = new HashMap<String,SignRef>();
//Point2D.Double background_offset = new Point2D.Double(0, 0);
@Override @Override
public void create() { public void create() {
@ -84,6 +88,9 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
font = new BitmapFont(Gdx.files.internal("fonts/AgencyFB.fnt")); font = new BitmapFont(Gdx.files.internal("fonts/AgencyFB.fnt"));
mainP = new Player(new Point2D.Double(1,1),"megamon_icon64.png"); mainP = new Player(new Point2D.Double(1,1),"megamon_icon64.png");
healthbar = new Texture("interface/healthbar.png"); healthbar = new Texture("interface/healthbar.png");
healthbar_horizontal = new Texture("interface/healthbar_horizontal.png");
//Gdx.graphics.setUndecorated(false);
//Gdx.graphics.setResizable(false);
//assets = new AssetManager(); //assets = new AssetManager();
/*assets.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); /*assets.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
@ -100,28 +107,26 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
Database.SetupInfoDatabase(); Database.SetupInfoDatabase();
Database.SetupMoveDatabase(); Database.SetupMoveDatabase();
Database.SetupMegamonDatabase(); Database.SetupMegamonDatabase();
Database.SetupEvolutionDatabase();
currentLevel = new Room(mainP.position,"Test Map"); currentLevel = new Room(mainP.position,"Test Map");
MegamonPet testPet = new MegamonPet("Test Name", MegamonPet testPet = new MegamonPet("Test Name",
new MegamonCreature("test_mini_sprite.png","test_sprite.png","test_sprite.png", megamonDatabase.get(2),
"Test Creature", "This is for testing purposes only.", 14, 60, CreatureType.NORMAL,
40,60,30,30,50,55,30,ExperienceRate.MEDIUM_FAST,new CreatureMoveLinker[]{}),
100); 100);
MegamonPet testPet2 = new MegamonPet("Test Name", MegamonPet testPet2 = new MegamonPet("Test Name",
new MegamonCreature("test_mini_sprite.png","test_sprite.png","test_sprite.png", megamonDatabase.get(5),
"Test Creature", "This is for testing purposes only.", 14, 60, CreatureType.NORMAL,
40,60,30,30,50,55,30,ExperienceRate.MEDIUM_FAST,new CreatureMoveLinker[]{}),
100); 100);
MegamonPet testPet3 = new MegamonPet("Test Name", MegamonPet testPet3 = new MegamonPet("Test Name",
new MegamonCreature("test_mini_sprite.png","test_sprite.png","test_sprite.png", megamonDatabase.get(0),
"Test Creature", "This is for testing purposes only.", 14, 60, CreatureType.NORMAL,
40,60,30,30,50,55,30,ExperienceRate.MEDIUM_FAST,new CreatureMoveLinker[]{}),
100); 100);
MegamonPet testPet4 = new MegamonPet("Test Name", MegamonPet testPet4 = new MegamonPet("Test Name",
new MegamonCreature("test_mini_sprite.png","test_sprite.png","test_sprite.png", megamonDatabase.get(3),
"Test Creature", "This is for testing purposes only.", 14, 60, CreatureType.NORMAL,
40,60,30,30,50,55,30,ExperienceRate.MEDIUM_FAST,new CreatureMoveLinker[]{}),
100); 100);
megamonDatabase.get(2).setSeen(true);
megamonDatabase.get(2).setCaught(true);
megamonDatabase.get(5).setSeen(true);
megamonDatabase.get(0).setSeen(true);
megamonDatabase.get(102).setSeen(true);
testPet.setHP((int)(Math.random()*testPet.getMaxHP())); testPet.setHP((int)(Math.random()*testPet.getMaxHP()));
testPet2.setHP((int)(Math.random()*testPet2.getMaxHP())); testPet2.setHP((int)(Math.random()*testPet2.getMaxHP()));
testPet3.setHP((int)(Math.random()*testPet3.getMaxHP())); testPet3.setHP((int)(Math.random()*testPet3.getMaxHP()));
@ -144,6 +149,9 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
Gdx.graphics.set Gdx.graphics.set
//Potential resizing code. //Potential resizing code.
}*/ }*/
if (megadexscreen!=null) {
megadexscreen.run();
} else
if (partyscreen!=null) { if (partyscreen!=null) {
partyscreen.run(); partyscreen.run();
} else } else
@ -178,6 +186,10 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
batch.begin(); batch.begin();
//batch.draw(img, 0, 0); //batch.draw(img, 0, 0);
if (megadexscreen!=null) {
megadexscreen.draw(batch);
}
else
if (partyscreen!=null) { if (partyscreen!=null) {
partyscreen.draw(batch); partyscreen.draw(batch);
} }
@ -199,6 +211,8 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
} }
//GlyphLayout size = font.draw(batch, "Test Text", 0, 32); //GlyphLayout size = font.draw(batch, "Test Text", 0, 32);
//font.draw(batch, "Test Text", Megamon.WINDOW_WIDTH-size.width, 128-size.height); //font.draw(batch, "Test Text", Megamon.WINDOW_WIDTH-size.width, 128-size.height);
/*DrawUtils.drawTiledImage(batch, healthbar, background_offset);
background_offset.setLocation(background_offset.x+0.4, background_offset.y+0.2);*/
batch.end(); batch.end();
framesPassed++; framesPassed++;
if (lastCheck.getTime().getSeconds()!=Calendar.getInstance().getTime().getSeconds()) { if (lastCheck.getTime().getSeconds()!=Calendar.getInstance().getTime().getSeconds()) {
@ -208,10 +222,15 @@ public class Megamon extends ApplicationAdapter implements ApplicationListener{
} }
} }
@Override
public void resize(int width, int height) {
//Gdx.graphics.setWindowedMode(width, (int)(width*((float)Megamon.WINDOW_HEIGHT)/Megamon.WINDOW_WIDTH));
//System.out.println("Resized: "+width+","+height);
}
@Override @Override
public void dispose () { public void dispose () {
batch.dispose(); batch.dispose();
img.dispose();
} }
public String toString() { public String toString() {

@ -29,8 +29,9 @@ public class MegamonCreature {
final int base_exp; final int base_exp;
final ExperienceRate exp_rate; final ExperienceRate exp_rate;
final List<CreatureMoveLinker> moveset; final List<CreatureMoveLinker> moveset;
final List<Evolution> evolution_rules; List<Evolution> evolution_rules;
boolean seenByPlayer=false; boolean seenByPlayer=false;
boolean caughtByPlayer=false;
public MegamonCreature(String mini_icon, String sprite, String back_sprite, public MegamonCreature(String mini_icon, String sprite, String back_sprite,
String name, String bio, int size, float weight, CreatureType type1, String name, String bio, int size, float weight, CreatureType type1,
@ -48,6 +49,14 @@ public class MegamonCreature {
CreatureMoveLinker...moveset) { CreatureMoveLinker...moveset) {
this(mini_icon,sprite,back_sprite,name,bio,size, weight,type1,CreatureType.NONE,base_hp,base_atk,base_def,base_spc,base_spd,catch_rate,base_exp,exp_rate,evolution_rules,moveset); this(mini_icon,sprite,back_sprite,name,bio,size, weight,type1,CreatureType.NONE,base_hp,base_atk,base_def,base_spc,base_spd,catch_rate,base_exp,exp_rate,evolution_rules,moveset);
} }
public MegamonCreature(String mini_icon, String sprite, String back_sprite,
String name, String bio, int size, float weight, CreatureType type1,
CreatureType type2, int base_hp, int base_atk, int base_def, int base_spc, int base_spd,
int catch_rate, int base_exp, ExperienceRate exp_rate,
CreatureMoveLinker...moveset) {
this(mini_icon,sprite,back_sprite,name,bio,size, weight,type1,type2,base_hp,base_atk,base_def,base_spc,base_spd,catch_rate,base_exp,exp_rate,new ArrayList<Evolution>(),moveset);
}
public MegamonCreature(String mini_icon, String sprite, String back_sprite, public MegamonCreature(String mini_icon, String sprite, String back_sprite,
String name, String bio, int size, float weight, CreatureType type1, String name, String bio, int size, float weight, CreatureType type1,
@ -77,6 +86,10 @@ public class MegamonCreature {
this.seenByPlayer=seenByPlayer; this.seenByPlayer=seenByPlayer;
} }
public void setCaught(boolean caughtByPlayer) {
this.caughtByPlayer=caughtByPlayer;
}
public SpriteCollection getSprites() { public SpriteCollection getSprites() {
return sprites; return sprites;
} }
@ -136,10 +149,17 @@ public class MegamonCreature {
public boolean isSeenByPlayer() { public boolean isSeenByPlayer() {
return seenByPlayer; return seenByPlayer;
} }
public boolean isCaughtByPlayer() {
return caughtByPlayer;
}
public List<Evolution> getEvolutionRules() { public List<Evolution> getEvolutionRules() {
return evolution_rules; return evolution_rules;
} }
public void setEvolutionRules(List<Evolution> rules) {
this.evolution_rules = rules;
}
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"("); StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()+"(");

@ -281,18 +281,18 @@ public class MegamonPet {
} }
public void setACCModifier(Integer acc_modifier) { public void setACCModifier(Integer acc_modifier) {
this.acc_modifier = acc_modifier; this.acc_modifier = acc_modifier;
} }
public void setATKIV(Integer atk_iv) { public void setATKIV(Integer atk_iv) {
this.atk_iv = atk_iv; this.atk_iv = atk_iv;
} }
public void setDEFIV(Integer def_iv) { public void setDEFIV(Integer def_iv) {
this.def_iv = def_iv; this.def_iv = def_iv;
} }
public void setSPDIV(Integer spd_iv) { public void setSPDIV(Integer spd_iv) {
this.spd_iv = spd_iv; this.spd_iv = spd_iv;
} }

@ -1,11 +1,18 @@
package sig.megamon.creature; package sig.megamon.creature;
import sig.megamon.Megamon;
public class CreatureMoveLinker { public class CreatureMoveLinker {
CreatureMove move; CreatureMove move;
int lvLearned=0; int lvLearned=0;
public CreatureMoveLinker(CreatureMove move, int lvLearnedAt) { public CreatureMoveLinker(String moveKeyName, int lvLearnedAt) {
this.move=move; if (Megamon.moveDatabase.containsKey(moveKeyName)) {
this.move = Megamon.moveDatabase.get(moveKeyName);
} else {
System.out.println("WARNING! Move \""+moveKeyName+"\" does not exist! Adding default move.");
this.move = Megamon.moveDatabase.get("M.Buster");
}
this.lvLearned=lvLearnedAt; this.lvLearned=lvLearnedAt;
} }
} }

@ -0,0 +1,69 @@
package sig.megamon.menu;
import com.badlogic.gdx.graphics.Color;
public class ColorCycler {
double r = 0;
double g = 0;
double b = 0;
double cyclespd = 0;
int stage = 1; //1 = Green+, 2 = Red-, 3 = Blue+, 4 = Green-, 5 = Red+, 6 = Blue-
public ColorCycler(Color startingColor, double cyclespd) {
this.r = startingColor.r;
this.g = startingColor.g;
this.b = startingColor.b;
this.cyclespd=cyclespd;
}
public void run() {
switch (stage) {
case 1:{
if (g<255) {
g=Math.min(255, g+cyclespd);
} else {
stage++;
}
}break;
case 2:{
if (r>0) {
r=Math.max(0, r-cyclespd);
} else {
stage++;
}
}break;
case 3:{
if (b<255) {
b=Math.min(255, b+cyclespd);
} else {
stage++;
}
}break;
case 4:{
if (g>0) {
g=Math.max(0, g-cyclespd);
} else {
stage++;
}
}break;
case 5:{
if (r<255) {
r=Math.min(255, r+cyclespd);
} else {
stage++;
}
}break;
case 6:{
if (b>0) {
b=Math.max(0, b-cyclespd);
} else {
stage=1;
}
}break;
}
}
public Color getCycleColor() {
return new Color((float)(r/255),(float)(g/255),(float)(b/255),1f);
}
}

@ -0,0 +1,49 @@
package sig.megamon.menu;
import java.awt.geom.Point2D;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import sig.megamon.utils.DrawUtils;
public class FancyBackground {
Point2D.Double offset = new Point2D.Double(0, 0);
Point2D.Double scrollspd = new Point2D.Double(0, 0);
Texture scrollbackground;
ColorCycler cycler;
Color color;
public FancyBackground(Texture background, Point2D.Double scrollspd, boolean cycleColors) {
this.scrollbackground=background;
this.scrollspd=scrollspd;
if (cycleColors) {
cycler = new ColorCycler(new Color(1,0,0,1),10);
} else {
color = new Color(0,0,0.5f,1);
}
}
public FancyBackground(Texture background, Point2D.Double scrollspd, Color staticColor) {
this(background,scrollspd,false);
this.color = staticColor;
}
public void run() {
if (cycler!=null) {
cycler.run();
}
offset.setLocation(offset.x+scrollspd.x, offset.y+scrollspd.y);
}
public void draw(SpriteBatch batch) {
if (cycler!=null) {
batch.setColor(cycler.getCycleColor());
} else {
batch.setColor(color);
}
DrawUtils.drawTiledImage(batch, scrollbackground, offset);
batch.setColor(new Color(1,1,1,1));
}
}

@ -1,5 +1,257 @@
package sig.megamon.menu; package sig.megamon.menu;
import java.awt.geom.Point2D;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Align;
import sig.megamon.*;
public class MegadexMenu { public class MegadexMenu {
static FancyBackground background = new FancyBackground(new Texture("interface/tiledbackground.png"),new Point2D.Double(0.4, 0.2),true);
static Texture menu = new Texture("interface/megadex.png");
final static int TOTALMEGAMON = 151;
int selection = 0;
int offset_displayed_selection = 0; //The top most selection that is visible.
int largestNumberSeen = 0;
boolean released=true;
int delaytimer = Megamon.CURSORDELAYTIMER*3;
final int fontheight = 36;
final int smallfontheight = 20;
final int boxheight = 458;
int lastkey = 0;
int hpval=0;
int atkval=0;
int defval=0;
int spcval=0;
int spdval=0;
final static int ticktime=2;
int changedelay=ticktime;
public MegadexMenu() {
largestNumberSeen = calculateLargestNumberSeen();
}
private int calculateLargestNumberSeen() {
for (int i=Megamon.megamonDatabase.size()-1;i>0;i--) {
if (Megamon.megamonDatabase.get(i).isSeenByPlayer()) {
return i;
}
}
return 0;
}
public void run() {
background.run();
if (Gdx.input.isKeyJustPressed(Megamon.CANCELKEY) ||
Gdx.input.isKeyJustPressed(Megamon.MENUKEY)) {
Megamon.megadexscreen=null;
return;
}
int keycheck = Megamon.MOVEDOWNKEY;
if (Gdx.input.isKeyJustPressed(keycheck)) {
released=false;
lastkey = keycheck;
MoveDown();
}
if (lastkey == keycheck) {
if (Gdx.input.isKeyPressed(keycheck) && !released) {
if (delaytimer--<=0) {
MoveDown();
delaytimer = Megamon.CURSORDELAYTIMER;
}
} else
if (!Gdx.input.isKeyPressed(keycheck) && !released) {
delaytimer = Megamon.CURSORDELAYTIMER*3;
released=true;
}
}
keycheck = Megamon.MOVEUPKEY;
if (Gdx.input.isKeyJustPressed(keycheck)) {
released=false;
lastkey = keycheck;
MoveUp();
}
if (lastkey == keycheck) {
if (Gdx.input.isKeyPressed(keycheck) && !released) {
if (delaytimer--<=0) {
MoveUp();
delaytimer = Megamon.CURSORDELAYTIMER;
}
} else
if (!Gdx.input.isKeyPressed(keycheck) && !released) {
delaytimer = Megamon.CURSORDELAYTIMER*3;
released=true;
}
}
keycheck = Megamon.MOVERIGHTKEY;
if (Gdx.input.isKeyJustPressed(keycheck)) {
released=false;
lastkey = keycheck;
MoveRight();
}
if (lastkey == keycheck) {
if (Gdx.input.isKeyPressed(keycheck) && !released) {
if (delaytimer--<=0) {
MoveRight();
delaytimer = Megamon.CURSORDELAYTIMER;
}
} else
if (!Gdx.input.isKeyPressed(keycheck) && !released) {
delaytimer = Megamon.CURSORDELAYTIMER*3;
released=true;
}
}
keycheck = Megamon.MOVELEFTKEY;
if (Gdx.input.isKeyJustPressed(keycheck)) {
released=false;
lastkey = keycheck;
MoveLeft();
}
if (lastkey == keycheck) {
if (Gdx.input.isKeyPressed(keycheck) && !released) {
if (delaytimer--<=0) {
MoveLeft();
delaytimer = Megamon.CURSORDELAYTIMER;
}
} else
if (!Gdx.input.isKeyPressed(keycheck) && !released) {
delaytimer = Megamon.CURSORDELAYTIMER*3;
released=true;
}
}
if (changedelay>0) {
changedelay--;
if (changedelay==0) {
changedelay = ticktime;
UpdateValues(Megamon.megamonDatabase.get(selection));
}
}
}
private void UpdateValues(MegamonCreature mon) {
hpval+=(mon.getHP()>hpval)?1:(mon.getHP()<hpval)?-1:0;
atkval+=(mon.getATK()>atkval)?1:(mon.getATK()<atkval)?-1:0;
defval+=(mon.getDEF()>defval)?1:(mon.getDEF()<defval)?-1:0;
spcval+=(mon.getSPC()>spcval)?1:(mon.getSPC()<spcval)?-1:0;
spdval+=(mon.getSPD()>spdval)?1:(mon.getSPD()<spdval)?-1:0;
}
private void MoveRight() {
selection = Math.min(selection+(boxheight/fontheight), largestNumberSeen);
MenuFollowsCursor();
}
private void MoveLeft() {
selection = Math.max(selection-(boxheight/fontheight), 0);
MenuFollowsCursor();
}
private void MoveDown() {
if (selection<largestNumberSeen) {
selection++;
MenuFollowsCursor();
}
}
private void MoveUp() {
if (selection>0) {
selection--;
MenuFollowsCursor();
}
}
private void MenuFollowsCursor() {
if (selection<offset_displayed_selection) {
offset_displayed_selection = selection;
}
if (selection - offset_displayed_selection>=(boxheight/fontheight)) {
offset_displayed_selection = selection - (boxheight/fontheight) + 1;
}
}
public void draw(SpriteBatch batch) {
background.draw(batch);
batch.draw(menu, 0, 0);
DrawMegamonMenu(batch);
}
private void DrawMegamonMenu(SpriteBatch batch) {
//First usable pixel: (12,12)
for (int i=0;i<boxheight/fontheight;i++) {
if (i+offset_displayed_selection<largestNumberSeen+1) {
MegamonCreature megamon = Megamon.megamonDatabase.get(offset_displayed_selection+i);
Megamon.font.setColor(new Color(1.0f,0.5f,0.5f,0.9f));
Megamon.font.draw(batch, Integer.toString(i+offset_displayed_selection+1), 20+16, Megamon.WINDOW_HEIGHT-fontheight-12-(i*fontheight)+fontheight/2, 10, Align.center, false);
if (megamon.isCaughtByPlayer()) {
Megamon.font.setColor(new Color(0.7f,1.0f,0.7f,1.0f));
} else {
Megamon.font.setColor(new Color(0.7f,0.7f,0.7f,1.0f));
}
String namedisplay = " "+(megamon.isSeenByPlayer()?megamon.getName():createTwitchyName());
Megamon.font.draw(batch, namedisplay, 32+16, Megamon.WINDOW_HEIGHT-fontheight-12-(i*fontheight)+fontheight/2, 0, namedisplay.length(), 256, Align.left, false, "...");
Megamon.font.setColor(Color.WHITE);
if (i+offset_displayed_selection == selection) {
Megamon.font.setColor(new Color(0.8f,0.8f,1f,0.9f));
Megamon.font.draw(batch, ">", 16, Megamon.WINDOW_HEIGHT-fontheight-12-(i*fontheight)+fontheight/2, 10, Align.left, false);
Megamon.font.setColor(Color.WHITE);
batch.draw(StartMenuBox.startmenu_highlight,16, Megamon.WINDOW_HEIGHT-fontheight-12-(i*fontheight)+fontheight/2-StartMenuBox.startmenu_highlight.getHeight()*2, StartMenuBox.startmenu_highlight.getWidth(),StartMenuBox.startmenu_highlight.getHeight()*3);
}
}
}
/*Image box: (332,120)
* Stats: (462,120)
* Bio: (332,150)
* Map: (332,468)
*/
MegamonCreature mon = Megamon.megamonDatabase.get(selection);
boolean seen = mon.isSeenByPlayer();
if (seen) {
Texture monImage = mon.getSprites().getSprite();
batch.draw(monImage, 332, Megamon.WINDOW_HEIGHT-120, 110, 110);
int i=1;
DialogBox.messageboxfont.draw(batch, "HP", 472, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 16, Align.center, false);
DialogBox.messageboxfont.draw(batch, "ATK", 472, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 16, Align.center, false);
DialogBox.messageboxfont.draw(batch, "DEF", 472, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 16, Align.center, false);
DialogBox.messageboxfont.draw(batch, "SPC", 472, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 16, Align.center, false);
DialogBox.messageboxfont.draw(batch, "SPD", 472, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 16, Align.center, false);
i=1;
/*batch.draw(Megamon.healthbar, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getHP()/600f))*Megamon.healthbar.getHeight()), 1, 1, 270, 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getHP()/600f))*Megamon.healthbar.getHeight()), false, false);
batch.draw(Megamon.healthbar, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getATK()/600f))*Megamon.healthbar.getHeight()), 1, 1, 270, 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getATK()/600f))*Megamon.healthbar.getHeight()), false, false);
batch.draw(Megamon.healthbar, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getDEF()/600f))*Megamon.healthbar.getHeight()), 1, 1, 270, 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getDEF()/600f))*Megamon.healthbar.getHeight()), false, false);
batch.draw(Megamon.healthbar, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getSPC()/600f))*Megamon.healthbar.getHeight()), 1, 1, 270, 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getSPC()/600f))*Megamon.healthbar.getHeight()), false, false);
batch.draw(Megamon.healthbar, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight), 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getSPD()/600f))*Megamon.healthbar.getHeight()), 1, 1, 270, 0, 0, Megamon.healthbar.getWidth(), Megamon.healthbar.getHeight()-(int)((1-(mon.getSPD()/600f))*Megamon.healthbar.getHeight()), false, false);*/
if (mon.getHP()>=100) {batch.setColor(new Color(1f,0.7f,0.7f,1f));} else {batch.setColor(Color.WHITE);}
batch.draw(Megamon.healthbar_horizontal, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight)+1-Megamon.healthbar_horizontal.getHeight(),0,0,(int)((hpval/200f)*Megamon.healthbar_horizontal.getWidth()*2),Megamon.healthbar_horizontal.getHeight());
if (mon.getATK()>=100) {batch.setColor(new Color(1f,0.7f,0.7f,1f));} else {batch.setColor(Color.WHITE);}
batch.draw(Megamon.healthbar_horizontal, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight)+1-Megamon.healthbar_horizontal.getHeight(),0,0,(int)((atkval/200f)*Megamon.healthbar_horizontal.getWidth()*2),Megamon.healthbar_horizontal.getHeight());
if (mon.getDEF()>=100) {batch.setColor(new Color(1f,0.7f,0.7f,1f));} else {batch.setColor(Color.WHITE);}
batch.draw(Megamon.healthbar_horizontal, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight)+1-Megamon.healthbar_horizontal.getHeight(),0,0,(int)((defval/200f)*Megamon.healthbar_horizontal.getWidth()*2),Megamon.healthbar_horizontal.getHeight());
if (mon.getSPC()>=100) {batch.setColor(new Color(1f,0.7f,0.7f,1f));} else {batch.setColor(Color.WHITE);}
batch.draw(Megamon.healthbar_horizontal, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight)+1-Megamon.healthbar_horizontal.getHeight(),0,0,(int)((spcval/200f)*Megamon.healthbar_horizontal.getWidth()*2),Megamon.healthbar_horizontal.getHeight());
if (mon.getSPD()>=100) {batch.setColor(new Color(1f,0.7f,0.7f,1f));} else {batch.setColor(Color.WHITE);}
batch.draw(Megamon.healthbar_horizontal, 500, Megamon.WINDOW_HEIGHT-(i++*smallfontheight)+1-Megamon.healthbar_horizontal.getHeight(),0,0,(int)((spdval/200f)*Megamon.healthbar_horizontal.getWidth()*2),Megamon.healthbar_horizontal.getHeight());
batch.setColor(Color.WHITE);
}
}
private String createTwitchyName() {
StringBuilder sb = new StringBuilder("");
for (int i=0;i<8;i++) {
if (Math.random()<=0.01) {
Character c = (char)(Character.getNumericValue('A')+(int)(Math.random()*26));
if (Math.random()<=0.5) {
c = (char)(Character.getNumericValue('a')+(int)(Math.random()*26));
}
sb.append(c);
} else {
sb.append("-");
}
}
return sb.toString();
}
} }

@ -74,13 +74,13 @@ public class MegamonPartyScreen {
WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING)+4,(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1)-64)); WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING)+4,(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1)-64));
Megamon.font.draw(batch, "Lv", Megamon.font.draw(batch, "Lv",
WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING),(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1))- WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING),(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1))-
mp.getCreature().getSprites().getMiniIcon().getHeight()*2-40); 16*2-40);
DialogBox.messageboxfont.draw(batch, Integer.toString(mp.getLevel()), DialogBox.messageboxfont.draw(batch, Integer.toString(mp.getLevel()),
WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING),(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1))- WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING),(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1))-
mp.getCreature().getSprites().getMiniIcon().getHeight()*2-72,24,Align.center,false); 16*2-72,24,Align.center,false);
DialogBox.messageboxfont.draw(batch, mp.getHP()+"/"+mp.getMaxHP(), DialogBox.messageboxfont.draw(batch, mp.getHP()+"/"+mp.getMaxHP(),
WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING),(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1))- WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING),(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1))-
mp.getCreature().getSprites().getMiniIcon().getHeight()*2-96,24,Align.center,false); 16*2-96,24,Align.center,false);
if ((float)mp.getHP()/mp.getMaxHP()<0.3) { if ((float)mp.getHP()/mp.getMaxHP()<0.3) {
batch.setColor(Color.RED); batch.setColor(Color.RED);
} }
@ -92,7 +92,7 @@ public class MegamonPartyScreen {
batch.setColor(Color.WHITE); batch.setColor(Color.WHITE);
Megamon.font.draw(batch, mp.getNickname(), Megamon.font.draw(batch, mp.getNickname(),
WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING)-24,(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1)- WINDOW_MARGIN+((i%3)*MEGAMON_SLOT_SPACING)-24,(int)(Megamon.WINDOW_HEIGHT/(i>2?1.9:1.1)-
mp.getCreature().getSprites().getMiniIcon().getHeight()*2-120),0,mp.getNickname().length(),100,Align.center,true,"..."); 16*2-120),0,mp.getNickname().length(),100,Align.center,true,"...");
i++; i++;
} }
} }

@ -10,7 +10,7 @@ public class StartMenuBox {
static Texture startmenu_background = new Texture("startmenu_box_middle.png"); static Texture startmenu_background = new Texture("startmenu_box_middle.png");
static Texture startmenu_background_bottom = new Texture("startmenu_box_bottom.png"); static Texture startmenu_background_bottom = new Texture("startmenu_box_bottom.png");
static Texture startmenu_background_top = new Texture("startmenu_box.png"); static Texture startmenu_background_top = new Texture("startmenu_box.png");
static Texture startmenu_highlight = new Texture("startmenu_highlight.png"); public static Texture startmenu_highlight = new Texture("startmenu_highlight.png");
int selection=0; int selection=0;
MenuItem[] menuitems = MenuItem.values(); MenuItem[] menuitems = MenuItem.values();
int menuitem_spacing = 28; int menuitem_spacing = 28;
@ -33,6 +33,7 @@ public class StartMenuBox {
if (Gdx.input.isKeyJustPressed(Megamon.ACTIONKEY)) { if (Gdx.input.isKeyJustPressed(Megamon.ACTIONKEY)) {
switch (menuitems[selection]) { switch (menuitems[selection]) {
case MEGADEX: case MEGADEX:
Megamon.megadexscreen = new MegadexMenu();
break; break;
case MEGAMON: case MEGAMON:
Megamon.partyscreen = new MegamonPartyScreen(); Megamon.partyscreen = new MegamonPartyScreen();

@ -1,5 +1,8 @@
package sig.megamon.utils; package sig.megamon.utils;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@ -12,4 +15,17 @@ public class DrawUtils {
batch.draw(tex, x, y); batch.draw(tex, x, y);
batch.setColor(new Color(1,1,1,1)); batch.setColor(new Color(1,1,1,1));
} }
public static void drawTiledImage(SpriteBatch batch, Texture image, Point2D.Double offset) {
int tileAmtX = (int)Math.ceil((double)Megamon.WINDOW_WIDTH/image.getWidth());
int tileAmtY = (int)Math.ceil((double)Megamon.WINDOW_HEIGHT/image.getHeight());
//int calls = 0;
for (int j=-1;j<tileAmtY+2;j++) {
for (int i=-1;i<tileAmtX+2;i++) {
//calls++;
batch.draw(image, (int)((offset.x%image.getWidth())+(i*image.getWidth())), (int)((offset.y%image.getHeight())+(j*image.getHeight())));
}
}
//System.out.println("Draw "+calls+" times.");
}
} }

Loading…
Cancel
Save