id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
3efab1c2-2994-42ac-9e19-d312f0bfa8d8 | public String getEventName(){
return NameofEvent;
} |
6cb48255-4992-409a-a7d1-676abc2a2507 | public String getActionsOnEvent(){
return ActionsOnEvent;
} |
b5ecdd0a-897b-4405-b74a-805648e4e716 | public String printInfo(){
return ActionsOnEvent + " for "+ NameofEvent + " Day - >" + Day + " Month ->" + Month;
} |
39621396-cb72-413f-a87e-aadc3e03500c | public void addComponentToPane(Container pane){
a.setLayout(new BorderLayout(100,10));
b.setLayout(new BorderLayout());
c.setLayout(new BorderLayout());
a.setLayout(new BorderLayout());
b.setLayout(new BorderLayout());
c.setLayout(new BorderLayout());
d.setLayout(new BorderLayout());
e.setLayout(new BorderLayout());
f.setLayout(new BorderLayout());
g.setLayout(new BorderLayout());
h.setLayout(new BorderLayout());
i.setLayout(new BorderLayout());
j.setLayout(new BorderLayout());
k.setLayout(new BorderLayout());
l.setLayout(new BorderLayout());
mainpanel.setLayout(new BorderLayout());
//------------------------------------
mainpanel.add(date,BorderLayout.NORTH);
mainpanel.add(year,BorderLayout.EAST);
mainpanel.add(month,BorderLayout.CENTER);
mainpanel.add(day,BorderLayout.WEST);
//------------------------------------
a.add(showholiday1,BorderLayout.NORTH);
a.add(showholiday2,BorderLayout.SOUTH);
a.add(showholiday3,BorderLayout.CENTER);
b.add(searchholiday1,BorderLayout.NORTH);
b.add(searchholiday2,BorderLayout.SOUTH);
b.add(searchholiday3,BorderLayout.CENTER);
c.add(addholiday1,BorderLayout.NORTH);
c.add(addholiday2,BorderLayout.SOUTH);
c.add(addholiday3,BorderLayout.CENTER);
d.add(removeholiday1,BorderLayout.NORTH);
d.add(removeholiday2,BorderLayout.SOUTH);
d.add(removeholiday3,BorderLayout.CENTER);
//--------------------------------------
e.add(showbirthday1,BorderLayout.NORTH);
e.add(showbirthday2,BorderLayout.SOUTH);
e.add(showbirthday3,BorderLayout.CENTER);
f.add(searchbirthday1,BorderLayout.NORTH);
f.add(searchbirthday2,BorderLayout.SOUTH);
f.add(searchbirthday3,BorderLayout.CENTER);
g.add(addbirthday1,BorderLayout.NORTH);
g.add(addbirthday2,BorderLayout.SOUTH);
g.add(addbirthday3,BorderLayout.CENTER);
h.add(removebirthday1,BorderLayout.NORTH);
h.add(removebirthday2,BorderLayout.SOUTH);
h.add(removebirthday3,BorderLayout.CENTER);
//----------------------------------------
i.add(showother1,BorderLayout.NORTH);
i.add(showother2,BorderLayout.SOUTH);
i.add(showother3,BorderLayout.CENTER);
j.add(searchother1,BorderLayout.NORTH);
j.add(searchother2,BorderLayout.SOUTH);
j.add(searchother3,BorderLayout.CENTER);
k.add(addother1,BorderLayout.NORTH);
k.add(addother2,BorderLayout.SOUTH);
k.add(addother3,BorderLayout.CENTER);
l.add(removeother1,BorderLayout.NORTH);
l.add(removeother2,BorderLayout.SOUTH);
l.add(removeother3,BorderLayout.CENTER);
//---------------------------------------
getContentPane().add(a, BorderLayout.CENTER);
getContentPane().add(b, BorderLayout.CENTER);
getContentPane().add(c, BorderLayout.CENTER);
getContentPane().add(d, BorderLayout.CENTER);
getContentPane().add(e, BorderLayout.CENTER);
getContentPane().add(f, BorderLayout.CENTER);
getContentPane().add(g, BorderLayout.CENTER);
getContentPane().add(h, BorderLayout.CENTER);
getContentPane().add(i, BorderLayout.CENTER);
getContentPane().add(j, BorderLayout.CENTER);
getContentPane().add(k, BorderLayout.CENTER);
getContentPane().add(l, BorderLayout.CENTER);
//--------------------------------------
showholiday2.addActionListener(this);
searchholiday2.addActionListener(this);
addholiday2.addActionListener(this);
removeholiday2.addActionListener(this);
showbirthday2.addActionListener(this);
searchbirthday2.addActionListener(this);
addbirthday2.addActionListener(this);
removebirthday2.addActionListener(this);
showother2.addActionListener(this);
searchother2.addActionListener(this);
addother2.addActionListener(this);
removeother2.addActionListener(this);
//---------------------------------------
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
JPanel comboBoxPane = new JPanel();
String comboBoxItems[] = { BUTTONPANEL,TEXTPANEL1,TEXTPANEL2,TEXTPANEL3,TEXTPANEL4,TEXTPANEL5,TEXTPANEL6,TEXTPANEL7,TEXTPANEL8,TEXTPANEL9,TEXTPANEL10,TEXTPANEL11,TEXTPANEL12};
JComboBox<Object> cb = new JComboBox<Object>(comboBoxItems);
cb.setEditable(false);
cb.addItemListener(this);
comboBoxPane.add(cb);
JPanel card1 = new JPanel();
JPanel card2 = new JPanel();
JPanel card3 = new JPanel();
JPanel card4 = new JPanel();
JPanel card5 = new JPanel();
JPanel card6 = new JPanel();
JPanel card7 = new JPanel();
JPanel card8 = new JPanel();
JPanel card9 = new JPanel();
JPanel card10 = new JPanel();
JPanel card11 = new JPanel();
JPanel card12 = new JPanel();
JPanel card13 = new JPanel();
card1.add(mainpanel);
card2.add(a);
card3.add(b);
card4.add(c);
card5.add(d);
card6.add(e);
card7.add(f);
card8.add(g);
card9.add(h);
card10.add(i);
card11.add(j);
card12.add(k);
card13.add(l);
cards = new JPanel(new CardLayout());
cards.add(card1, BUTTONPANEL);
cards.add(card2, TEXTPANEL1);
cards.add(card3, TEXTPANEL2);
cards.add(card4, TEXTPANEL3);
cards.add(card5, TEXTPANEL4);
cards.add(card6, TEXTPANEL5);
cards.add(card7, TEXTPANEL6);
cards.add(card8, TEXTPANEL7);
cards.add(card9, TEXTPANEL8);
cards.add(card10, TEXTPANEL9);
cards.add(card11, TEXTPANEL10);
cards.add(card12, TEXTPANEL11);
cards.add(card13, TEXTPANEL11);
pane.add(comboBoxPane, BorderLayout.PAGE_START);
pane.add(cards, BorderLayout.CENTER);
} |
6f7f7f37-6f16-400c-84db-49334a866c33 | public void itemStateChanged(ItemEvent evt) {
CardLayout cl = (CardLayout)(cards.getLayout());
cl.show(cards, (String)evt.getItem());
} |
fd126640-d99d-4180-bb3f-c906060ccfe8 | public void actionPerformed(ActionEvent a){
Calendar c1 = new Calendar(2014);
try{
c1.readinBirthday();
c1.readinHoliday();
c1.readinOther();
if(a.getSource() == showholiday2){
showholiday3.setText("");
for(int i= 0;i<c1.holiday.length;i++){
showholiday3.append(c1.sortHoliday(c1.readinHoliday())[i].printInfo());
if(i == c1.holiday.length-1){
}else{
showholiday3.append("\n");
}
}
}else if(a.getSource() == showbirthday2){
showbirthday3.setText("");
for(int i = 0;i<c1.birthday.length;i++){
showbirthday3.append(c1.sortBirthday(c1.birthday)[i].printInfo());
if(i == c1.birthday.length-1){
}else{
showbirthday3.append("\n");
}
}
}else if(a.getSource() == showother2){
showother3.setText("");
for(int i = 0;i<c1.other.length;i++){
showother3.append(c1.sortOther(c1.other)[i].printInfo());
if(i == c1.other.length-1){
}else{
showother3.append("\n");
}
}
}else if(a.getSource() == searchholiday2){
String b = searchholiday3.getText().trim();
if(c1.searchHoliday(b,c1.sortHoliday(c1.holiday),0,c1.holiday.length) == -1){
searchholiday3.setText("Holiday not found , try again");
}else{
searchholiday3.setText(c1.holiday[c1.searchHoliday(b,c1.sortHoliday(c1.holiday),0,c1.holiday.length)].printInfo());
}
}else if(a.getSource() == searchbirthday2){
String []b = new String[2];
b = searchbirthday3.getText().split(delimeter);
if(c1.searchBirthday(b[0],b[1],c1.sortBirthday(c1.birthday),0,c1.birthday.length) == -1){
searchbirthday3.setText("Birthday not found , try again");
}else{
searchbirthday3.setText(c1.holiday[c1.searchBirthday(b[0].trim(),b[1].trim(),c1.sortBirthday(c1.birthday),0,c1.birthday.length)].printInfo());
}
}else if(a.getSource() == searchother2){
String b = searchother3.getText().trim();
if(c1.searchOther(b,c1.sortOther(c1.other),0,c1.other.length) == -1){
searchother3.setText("Event not found , try again");
}else{
searchother3.setText(c1.other[c1.searchOther(b,c1.sortOther(c1.other),0,c1.other.length)].printInfo());
}
}else if(a.getSource() == addholiday2){
String []c = new String[2];
c = addholiday3.getText().split(delimeter);
int day1 = Integer.parseInt(c[1].trim());
int month1 = Integer.parseInt(c[2].trim());
c1.addHoliday(c[0].trim(),day1,month1);
c1.writeoutHoliday();
addholiday3.setText("Holiday added");
}else if(a.getSource() == addbirthday2){
String []c = new String[3];
c = addbirthday3.getText().split(delimeter);
int day1 = Integer.parseInt(c[2].trim());
int month1 = Integer.parseInt(c[3].trim());
c1.addBirthday(c[0].trim(),c[1].trim(),day1,month1);
addholiday3.setText("Birthday added");
}else if(a.getSource() == addother2){
String []c = new String[3];
c = addother3.getText().split(delimeter);
int day1 = Integer.parseInt(c[2].trim());
int month1 = Integer.parseInt(c[3].trim());
c1.addBirthday(c[0].trim(),c[1].trim(),day1,month1);
addholiday3.setText("Event added");
}else if(a.getSource() == removeholiday2){
String c = removeholiday3.getText();
if(c1.searchHoliday(c,c1.holiday,0,c1.holiday.length) == -1){
removeholiday3.setText("Holiday not found, try again");
}else{
c1.deleteHoliday(c1.searchHoliday(c,c1.holiday,0,c1.holiday.length));
removeholiday3.setText("Hoiday removed");
c1.writeoutHoliday();
}
}else if(a.getSource() == removebirthday2){
String []c = new String[3];
c = removebirthday3.getText().split(delimeter);
if(c1.searchBirthday(c[0],c[1],c1.birthday,0,c1.holiday.length) == -1){
removebirthday3.setText("Birthday not found, try again");
}else{
c1.deleteBirthday(c1.searchBirthday(c[0],c[1],c1.birthday,0,c1.holiday.length));
removebirthday3.setText("Birthday removed");
c1.writeoutBirthday();
}
}else if(a.getSource() == removeother2){
String []c = new String[3];
c = removeother3.getText().split(delimeter);
if(c1.searchOther(c[0],c1.other,0,c1.holiday.length) == -1){
removeother3.setText("Event not found, try again");
}else{
c1.deleteOther(c1.searchOther(c[0],c1.other,0,c1.holiday.length));
removeother3.setText("Event removed");
c1.writeoutOther();
}
}else{
showholiday2.setText(" ");
}
}catch(IOException obj){
System.out.println("failed");
}
} |
a0516474-dd60-4e3a-adc1-73cbfe78aa52 | public static void main(String str[])throws IOException{
JFrame frame = new JFrame("Calendar Module");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CalendarModule test = new CalendarModule();
test.addComponentToPane(frame.getContentPane());
frame.pack();
frame.setSize (700, 500);
frame.setVisible(true);
} |
b6d92361-cd68-40f8-be20-a25cc68e9c21 | public Holiday(String NoH,int d,int m){
super (d,m);
NameofHoliday = NoH;
} |
bf7b925c-a9c2-4608-949d-fcdd1acb6c94 | public int getDay(){
return Day;
} |
53a59be5-a1cf-4a78-9014-69d864acdbc5 | public int getMonth(){
return Month;
} |
3b904c29-1bc1-4b76-ae1f-83bdaf46e895 | public String getNameofHoliday(){
return NameofHoliday;
} |
2e7bf3d8-aed8-470b-8170-a6efe40905bb | public String printInfo(){
return NameofHoliday + " Day - >" + Day + " Month ->" + Month;
} |
ddf01583-55b1-46d1-a9c3-18060bedc33c | public TextPoint(String text, int x, int y, Color colour){
this.text = text;
this.x = x;
this.y = y;
this.colour = colour;
} |
1c99f7c8-dd06-4300-a75a-17b05a120d3f | public Floor(int x, int y, int type, int pass){
this.x = x;
this.y = y;
this.type = type;
this.pass = pass;
} |
b1678265-fc11-4fd7-8110-26e1387edfab | public void buildLibrary(){
try{
//menu 1
wave = ImageIO.read(new File("res/bgs/waves.png"));
title1 = ImageIO.read(new File("res/bgs/Title1.png"));
title2 = ImageIO.read(new File("res/bgs/Title2.png"));
title3 = ImageIO.read(new File("res/bgs/Title3.png"));
title4 = ImageIO.read(new File("res/bgs/Title4.png"));
title5 = ImageIO.read(new File("res/bgs/Title5.png"));
title6 = ImageIO.read(new File("res/bgs/Title6.png"));
titleSky = ImageIO.read(new File("res/bgs/TitleSky.png"));
//introductory images
sun = ImageIO.read(new File("res/bgs/IntroSun.png"));
planet = ImageIO.read(new File("res/bgs/IntroPlanet.png"));
riftSummitbgs = ImageIO.read(new File("res/bgs/RiftSummitbgs.png"));
//menu items
selection = ImageIO.read(new File("res/sprites/Option.png"));
selected = ImageIO.read(new File("res/sprites/Selected.png"));
textDisplay = ImageIO.read(new File("res/sprites/TextBox.png"));
gSelection = ImageIO.read(new File("res/sprites/GameOption.png"));
gSelected = ImageIO.read(new File("res/sprites/GameSelected.png"));
//character sprites
voidBall = ImageIO.read(new File("res/sprites/Void.png"));
voidBall2 = ImageIO.read(new File("res/sprites/Void (F2).png"));
sapphionU = ImageIO.read(new File("res/sprites/Sapphion (Back).png"));
sapphionD = ImageIO.read(new File("res/sprites/Sapphion.png"));
sapphionL = ImageIO.read(new File("res/sprites/Sapphion (Left).png"));
sapphionR = ImageIO.read(new File("res/sprites/Sapphion (Right).png"));
//locations
riftSummit = ImageIO.read(new File("res/bgs/RiftSummit.png"));
//terrain types
jungleBG = ImageIO.read(new File("res/bgs/JungleBG.png"));
rockyBG = ImageIO.read(new File("res/bgs/RockyBG.png"));
rockyU = ImageIO.read(new File("res/bgs/RockyWall (Top).png"));
rockyL = ImageIO.read(new File("res/bgs/RockyWall (Left).png"));
rockyD = ImageIO.read(new File("res/bgs/RockyWall (Bottom).png"));
rockyR = ImageIO.read(new File("res/bgs/RockyWall (Right).png"));
rockyUR = ImageIO.read(new File("res/bgs/RockyWall (UR).png"));
rockyDR = ImageIO.read(new File("res/bgs/RockyWall (DR).png"));
rockyDL = ImageIO.read(new File("res/bgs/RockyWall (DL).png"));
rockyUL = ImageIO.read(new File("res/bgs/RockyWall (UL).png"));
rockyB = ImageIO.read(new File("res/bgs/RockyBlock.png"));
//UI elements for gameplay
HP = ImageIO.read(new File("res/sprites/HPslice.png"));
HUD = ImageIO.read(new File("res/sprites/HUD.png"));
menuBox = ImageIO.read(new File("res/sprites/menuBox.png"));
}catch(Exception er){
System.out.println("A File must be missing!\nCannot make stream and grab images.\nError: "+er);
}
RiftFrame.tick.start();
} |
72c00d1a-163b-4b52-aeb6-8f681696579f | public Sprite(BufferedImage img, int x, int y){
this.img = img;
this.x = x;
this.y =y;
} |
6f0ca366-76d8-4954-94d6-95ec8b4268e0 | public void readTileSet() throws Exception{
BufferedReader tileReader = null;
tileReader = new BufferedReader(new FileReader("src/tileset.dat"));
int data = 0;
char dat = 0;
String da;
int d;
int count = 0;
int line = 0;
while ( -1 != (data = tileReader.read()) ) {
if (data == 13){
//do nothing
} else if (data == 10){ //new line
line ++;
count = 0;
} else {
dat = (char)data;
da = ""+dat;
d = Integer.parseInt(da);
if (d>0){
tiles.add(new Floor(count,line,d,0));
} else{
tiles.add(new Floor(count,line,d,1));
}
count++;
}
}
tileReader.close();
} |
42f8b8d0-24bf-44fe-8dc1-96f7ce09803c | public void update(Creature a){
//System.out.println("updating images for player");
BufferedImage[][] imgs = new BufferedImage[4][2];
switch(a.stat[0]){
case 0:
//System.out.println("yep 0");
imgs[0][0] = ImageLibrary.sapphionU;
imgs[1][0] = ImageLibrary.sapphionR;
imgs[2][0] = ImageLibrary.sapphionD;
imgs[3][0] = ImageLibrary.sapphionL;
imgs[0][1] = ImageLibrary.sapphionU;
imgs[1][1] = ImageLibrary.sapphionR;
imgs[2][1] = ImageLibrary.sapphionD;
imgs[3][1] = ImageLibrary.sapphionL;break;
case 1:
System.out.println("yep 1");
imgs[0][0] = ImageLibrary.sapphionU;
imgs[1][0] = ImageLibrary.sapphionR;
imgs[2][0] = ImageLibrary.sapphionD;
imgs[3][0] = ImageLibrary.sapphionL;
imgs[0][1] = ImageLibrary.sapphionU;
imgs[1][1] = ImageLibrary.sapphionR;
imgs[2][1] = ImageLibrary.sapphionD;
imgs[3][1] = ImageLibrary.sapphionL;break;
case 4:
System.out.println("yep 4");
imgs[0][0] = ImageLibrary.sapphionU;
imgs[1][0] = ImageLibrary.sapphionR;
imgs[2][0] = ImageLibrary.sapphionD;
imgs[3][0] = ImageLibrary.sapphionL;
imgs[0][1] = ImageLibrary.sapphionU;
imgs[1][1] = ImageLibrary.sapphionR;
imgs[2][1] = ImageLibrary.sapphionD;
imgs[3][1] = ImageLibrary.sapphionL;break;
case 7:
System.out.println("yep 5");
imgs[0][0] = ImageLibrary.sapphionU;
imgs[1][0] = ImageLibrary.sapphionR;
imgs[2][0] = ImageLibrary.sapphionD;
imgs[3][0] = ImageLibrary.sapphionL;
imgs[0][1] = ImageLibrary.sapphionU;
imgs[1][1] = ImageLibrary.sapphionR;
imgs[2][1] = ImageLibrary.sapphionD;
imgs[3][1] = ImageLibrary.sapphionL;break;
case 100:
System.out.println("yep 100");
imgs[0][0] = ImageLibrary.sapphionU;
imgs[1][0] = ImageLibrary.sapphionR;
imgs[2][0] = ImageLibrary.sapphionD;
imgs[3][0] = ImageLibrary.sapphionL;
imgs[0][1] = ImageLibrary.sapphionU;
imgs[1][1] = ImageLibrary.sapphionR;
imgs[2][1] = ImageLibrary.sapphionD;
imgs[3][1] = ImageLibrary.sapphionL;break;
}
a.img = imgs;
} |
23140087-3597-4cd1-8634-29b4172ce6bd | public void actionPerformed(ActionEvent e){
if(drawing.frame <29){
drawing.frame++;
}else{
drawing.frame=0;
}
if(startTime==true){
time++;
}else{
time=0;
}
MenuSelect.menuItems = MenuSelect.Dmenu.get(MenuSelect.menu);//if out of bounds errors here then create menu is doing something wrong
MenuSelect.background(MenuSelect.menuItems);
if(MenuSelect.play == true){
//gen.render();
if(control == true){
imgs.add(new Sprite(ImageLibrary.HUD,0,0));
RiftGraphics.drawText.add(new TextPoint("HP",24,20,new Color(100,255,20)));
for(int a=0; a<120;a++){
imgs.add(new Sprite(ImageLibrary.HP,111+a,0));
}
}
}
if(MenuSelect.selectPos > MenuSelect.menuItems.options[MenuSelect.dialogNum] -1){//makes it so you can not choose higher or lower than the amount of options
MenuSelect.selectPos = 0;
}else if(MenuSelect.selectPos < 0){
MenuSelect.selectPos = MenuSelect.menuItems.options[MenuSelect.dialogNum] -1;
}
select.Menu(drawing.frame);
gen.update(MenuSelect.player);
for(int a=0;a<RiftGraphics.image.size();a++){//adds all the images given from RiftGraphics into an arraylist of sprites
img = new Sprite((BufferedImage)RiftGraphics.image.get(a),(int)(RiftGraphics.imageX.get(a)),(int)(RiftGraphics.imageY.get(a)));
imgs.add(img);
}
MenuSelect.setup(MenuSelect.menuItems);
new Thread(new Runnable(){//starts a new thread
public void run() {
drawing.repaint();//uses the repaint from the RiftGraphics class
}
}).start();
} |
6f401378-c54e-4495-b1f3-eb2221ca0544 | public void run() {
drawing.repaint();//uses the repaint from the RiftGraphics class
} |
aad53851-ca96-4426-9af0-ea95a8990199 | public static void main(String[] args) {
MenuSelect select = new MenuSelect();
//the properties of the frame and components
GameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GameFrame.add(drawing, BorderLayout.CENTER);//allows the use of paint component
GameFrame.addKeyListener(select);
GameFrame.setFocusable(true);
GameFrame.setSize(614,700);
GameFrame.setResizable(false);
GameFrame.setVisible(true);
RiftFrame.tick.setActionCommand("menu1");//the tick event for menu 1
MenuSelect.menu=0;
library.buildLibrary();//loads all the images needed
//gen.render(); //create the tileset
try {
gen.readTileSet();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("creating menu");
MenuSelect.createMenus();
} |
528307d6-5b7d-49cd-889b-213c080f2d8a | public Creature(BufferedImage[][] img, int x, int y, int d, int[] ID){
this.img = img;
this.x = x;
this.y = y;
this.d = d;
this.stat = ID;
} |
00760603-1482-4b4c-90b3-a718e6d068af | public void keyTyped(KeyEvent key){} |
5148de79-cfec-4687-99fe-ea698c8396cb | public void keyPressed(KeyEvent key){
System.out.println("playerX = "+player.x+"\nplayerY = "+player.y+"\nscreenPosX: "+LevelGen.mapPosX+" screenPosY: "+LevelGen.mapPosY+" screenPosX/30+10 " + (LevelGen.mapPosX/32 + 10) + "," + (LevelGen.mapPosY/32 + 11)); //if 0,0 then (28,29)
if (key.getKeyCode() == KeyEvent.VK_W) { //WASD w key
up = true;
if(RiftFrame.control ==true){
if (player.d == 0){
if(down == false){
for(Floor a: LevelGen.tiles){
if (a.pass == 0&&a.y==((player.y) -1)&&a.x==player.x){
clear = false;
}
}
if(clear==true){
player.y-=1;
LevelGen.mapPosY-=32;
}else{
clear = true;
}
}
}else{
player.d =0;
}
}
}
else if (key.getKeyCode() == KeyEvent.VK_S) { //WASD s key
down = true;
if(RiftFrame.control ==true){
if (player.d == 2){
if(up == false){
for(Floor a: LevelGen.tiles){
if (a.pass == 0&&a.y==(player.y + 1)&&a.x==player.x){
clear = false;
}
}
if(clear==true){
player.y+=1;
LevelGen.mapPosY+=32;
}else{
clear = true;
}
}
}else{
player.d =2;
}
}
}else if (key.getKeyCode() == KeyEvent.VK_A){ //WASD a key
left = true;
if(RiftFrame.control ==true){
if (player.d == 3){
if(right == false){
for(Floor a: LevelGen.tiles){
if (a.pass == 0&&a.y==player.y&&a.x==player.x-1){
clear = false;
}
}
if(clear==true){
player.x-=1;
LevelGen.mapPosX-=32;
}else{
clear = true;
}
}
}else{
player.d =3;
}
}
}else if (key.getKeyCode() == KeyEvent.VK_D){ //WASD d key
right = true;
if(RiftFrame.control ==true){
if (player.d == 1){
if(left == false){
for(Floor a: LevelGen.tiles){
if (a.pass == 0&&a.y==player.y&&a.x==player.x+1){
clear = false;
}
}
if(clear==true){
player.x+=1;
LevelGen.mapPosX+=32;
}else{
clear = true;
}
}
}else{
player.d =1;
}
}
}
if((key.getKeyCode() == KeyEvent.VK_SPACE || key.getKeyCode() == KeyEvent.VK_ENTER) && RiftFrame.menuControl == true){
if(menu ==0){
switch (selectPos){
case 0:
menu = 1;//start the game
RiftFrame.menuControl = false;
RiftFrame.startTime = false;break;
case 1:
menu = 3;
RiftFrame.tick.setActionCommand("menu3");break; //goto main menu
case 2:
System.exit(0);break;
default: //TODO add default
break;
}
}else if(menu ==1){//game start
}else if(menu ==2){ //character select
if(dialogNum==0){
switch (selectPos){
case 0:
dialogNum++;break;
case 1:
dialogNum =2;break;
}
}else if(dialogNum==1){
dialogNum=2;
}else if(dialogNum==2){
switch (selectPos){
case 0:
element = "Fire";player.stat[0]=1;break;
case 1:
element = "Earth";player.stat[0]=1;break;
case 2:
element = "Water";player.stat[0]=1;break;
case 3:
element = "Air";player.stat[0]=1;break;
case 4:
element = "Psychic";player.stat[0]=1;break;
case 5:
element = "Electric";player.stat[0]=1;break;
}
Dmenu.get(2).text[3][0] = "Is the element " + element + " okay?";
dialogNum=3;
}else if(dialogNum ==3){
switch (selectPos){
case 0:
menu=4;
dialogNum =0;break;
case 1:
dialogNum =2;
}
}
}else if(menu ==3){
switch (selectPos){
case 0:
menu = 4;break;
case 1:
break;
case 2:
break;
case 3:
menu = 0;break;
}
}else if(menu==5){
switch (selectPos){
case 0:
break;
case 4:
menu = 4;break;
}
}
}
} |
a1665c63-3bc1-4913-9bda-45c16a59149c | public void keyReleased(KeyEvent key){
if (key.getKeyCode() == KeyEvent.VK_W) { //WASD w key
up = false;
selectPos--;
}
else if (key.getKeyCode() == KeyEvent.VK_S) { //WASD s key
down = false;
selectPos++;
}else if (key.getKeyCode() == KeyEvent.VK_A){
left = false;
}else if (key.getKeyCode() == KeyEvent.VK_D){
right = false;
}else if(key.getKeyCode() == KeyEvent.VK_E){
if(menu == 4){
menu = 5;
}
}
} |
52d1f9ae-4c32-4d01-b11a-39a004200533 | public void Menu(int frame){
if(menu ==0){
//since there is already a loop that accumulates the frame that is in riftframe we reference it
if(frame <5){//determines which frame to display
RiftGraphics.imageX.add(165);
RiftGraphics.imageY.add(100);
RiftGraphics.image.add(ImageLibrary.title1);
}else if(frame <10){
RiftGraphics.imageX.add(165);
RiftGraphics.imageY.add(100);
RiftGraphics.image.add(ImageLibrary.title2);
}else if(frame <15){
RiftGraphics.imageX.add(165);
RiftGraphics.imageY.add(100);
RiftGraphics.image.add(ImageLibrary.title3);
}else if(frame <20){
RiftGraphics.imageX.add(165);
RiftGraphics.imageY.add(100);
RiftGraphics.image.add(ImageLibrary.title4);
}else if(frame <25){
RiftGraphics.imageX.add(165);
RiftGraphics.imageY.add(100);
RiftGraphics.image.add(ImageLibrary.title5);
}else{
RiftGraphics.imageX.add(165);
RiftGraphics.imageY.add(100);
RiftGraphics.image.add(ImageLibrary.title6);
}
if (drawing.waveX<658){ //inside screen -frame movement
drawing.waveX+=2; //move it
}else{ //outside screen
drawing.waveX = -660; //put it back so it can loop through again
}
RiftGraphics.imageX.add(drawing.waveX);
RiftGraphics.imageY.add(0);
RiftGraphics.image.add(ImageLibrary.wave);
if (drawing.waveX2<658){
drawing.waveX2 += 2;
}else{
drawing.waveX2=-660;
}
RiftGraphics.imageX.add(drawing.waveX2);
RiftGraphics.imageY.add(0);
RiftGraphics.image.add(ImageLibrary.wave);
}else if(menu ==1 && RiftFrame.menuControl == true){
dialogNum++;
RiftFrame.time =0;
RiftFrame.menuControl = false;
if(dialogNum == Dmenu.get(1).sections){
dialogNum =0;
menu =2;
}
}else if(menu == 2){
if(frame < 15){
RiftGraphics.imageX.add(295);
RiftGraphics.imageY.add(370);
RiftGraphics.image.add(ImageLibrary.voidBall);
}else{
RiftGraphics.imageX.add(295);
RiftGraphics.imageY.add(370);
RiftGraphics.image.add(ImageLibrary.voidBall2);
}
for(int a=0;a<4;a++){//only updates when dialogNum changes
int moveX=(int) (2 * (Math.pow(a, 2)) -20);//parabola for awesomeness
Dmenu.get(2).bgds[a][0] = new Sprite(ImageLibrary.riftSummitbgs,moveX,0);
background(Dmenu.get(2));
}
}else if(menu == 3){
if (drawing.waveX<658){ //inside screen -frame movement
drawing.waveX+=2; //move it
}else{ //outside screen
drawing.waveX = -660; //put it back so it can loop through again
}
RiftGraphics.imageX.add(drawing.waveX);
RiftGraphics.imageY.add(0);
RiftGraphics.image.add(ImageLibrary.wave);
if (drawing.waveX2<658){
drawing.waveX2 += 2;
}else{
drawing.waveX2=-660;
}
RiftGraphics.imageX.add(drawing.waveX2);
RiftGraphics.imageY.add(0);
RiftGraphics.image.add(ImageLibrary.wave);
}else if(menu == 4){
RiftFrame.control = true;
play = true;
}else if(menu == 5){
RiftFrame.control = false;
RiftFrame.menuControl = true;
RiftGraphics.imageX.add(320);
RiftGraphics.imageY.add(350);
RiftGraphics.image.add(ImageLibrary.menuBox);
}
} |
70bbae83-ef40-4c5a-9e0c-2f2f7de0bfca | public static void createMenus(){
int[] options;
String[][] text;
Sprite[][] bgds;
int[] time;
/*
* dialog makes it so there can be dialog in a text field as well as decisions,
*
*/
/*MAIN MENU*/
menuItems.dialog = false;//makes it a main menu
menuItems.sections = 1;
options = new int[1];
options[0] = 3;
menuItems.options = options;
text = new String[1][3];
text[0][0] = "New Game";
text[0][1] = "Options";
text[0][2] = "Exit";
menuItems.text = text;
bgds = new Sprite[1][1];
bgds[0][0] = new Sprite(ImageLibrary.titleSky,0,0);//drawn on a seperate method, done first
menuItems.bgds = bgds;
Dmenu.add(menuItems);
System.out.println("menus: " + MenuSelect.Dmenu.size());
/*INTRODUCTION SCENE*/
menuItems = new Menus(new int[1], new int[1], false, 0, new String[1][1], new Sprite[1][1]);
menuItems.dialog = true;
menuItems.sections = 3;
options = new int[3];
options[0] = 0;
options[1] = 0;
options[2] = 0;
menuItems.options = options;
time = new int[3];
time[0] =100;
time[1] =350;
time[2] = 350;
menuItems.time = time;
text = new String[3][1];
text[0][0] = "There once existed a realm untouched by anything. It was peaceful.";
text[1][0] = "Within Dwelled only two planets, each with different views on lifestyle. One believed\n"+
"in renewal, where life is an unended stream that should not be stopped.\n"+
"The other believed in preservation where life is etheral force that should not be trifled \n"+
"with. These planets knew not of each other";
text[2][0] = "Then a Rift, opened its self in between the two planets, few say it was\n"+
"the summoners on the other side whom opened it. As the beings from the\n"+
"side tried to step through a guardian from the cosmos appeared.\n"+
"This being allowed only those who were worty to enter.";
menuItems.text = text;
bgds = new Sprite[3][1];
bgds[0][0] = new Sprite(ImageLibrary.sun,0,0);
bgds[1][0] = new Sprite(ImageLibrary.planet,0,0);
bgds[2][0] = new Sprite(ImageLibrary.planet,0,0);
menuItems.bgds = bgds;
Dmenu.add(menuItems);
System.out.println("menus: " + MenuSelect.Dmenu.size());
/*CHARACTER CREATION*/
menuItems = new Menus(new int[1], new int[1], false, 0, new String[1][1], new Sprite[1][1]);
menuItems.dialog = true;
menuItems.sections = 4;
options = new int[4];
options[0] = 2;
options[1] = 1;
options[2] = 6;
options[3] = 2;
menuItems.options = options;
time = new int[4];
time[0] = 150;
time[1] = 350;
time[2] = 200;
time[3] = 150;
menuItems.time = time;
text = new String[4][7];
text[0][0] = "Welcome being, before I begin do you want me to overview the controls for you?";
text[0][1] = "Yes";
text[0][2] = "No";
text[1][0] = "The WASD keys are for moving around, the space key is to interact. The e key opens\n"+
"the menu and the q key closes it or backs out of the menu you are in.\n"+
"When in the menu space or enter selects options and the WASD keys navigate.\n"+
"z activates the quick selected attack and f is for quick selected items.";
text[1][1] = "Okay";
text[2][0] = "Now finally, which element do you perfer?";
text[2][1] ="Fire";
text[2][2] ="Earth";
text[2][3] ="Water";
text[2][4] ="Air";
text[2][5] ="Psychic";
text[2][6] ="Electric";
text[3][0] = "Is the element " + element + " okay?";
text[3][1] = "Yes";
text[3][2] = "No";
menuItems.text = text;
bgds = new Sprite[4][2];
bgds[0][0] = new Sprite(ImageLibrary.riftSummitbgs,0,20);
bgds[0][1] = new Sprite(ImageLibrary.riftSummit,0,20);
bgds[1][0] = new Sprite(ImageLibrary.riftSummitbgs,0,20);
bgds[1][1] = new Sprite(ImageLibrary.riftSummit,0,20);
bgds[2][0] = new Sprite(ImageLibrary.riftSummitbgs,0,20);
bgds[2][1] = new Sprite(ImageLibrary.riftSummit,0,20);
bgds[3][0] = new Sprite(ImageLibrary.riftSummitbgs,0,20);
bgds[3][1] = new Sprite(ImageLibrary.riftSummit,0,20);
menuItems.bgds = bgds;
Dmenu.add(menuItems);
System.out.println("menus: " + MenuSelect.Dmenu.size());
/*OPTIONS MENU*/
menuItems = new Menus(new int[1], new int[1], false, 0, new String[1][1], new Sprite[1][1]);
menuItems.dialog = false;
menuItems.sections = 1;
options = new int[1];
options[0] = 4;
menuItems.options = options;
text = new String[1][4];
text[0][0] = "Awesomeness";
text[0][1] = "Grommet";
text[0][2] = "Coolness";
text[0][3] = "Back";
menuItems.text = text;
bgds = new Sprite[1][1];
bgds[0][0] = new Sprite(ImageLibrary.titleSky,0,0);
menuItems.bgds = bgds;
Dmenu.add(menuItems);
System.out.println("menus: " + MenuSelect.Dmenu.size());
/*GAMEPLAY*/
menuItems = new Menus(new int[1], new int[1], false, 0, new String[1][1], new Sprite[1][1]);
menuItems.dialog = true;
menuItems.sections = 1;
options = new int[1];
options[0] = 0;
menuItems.options = options;
time = new int[1];
time[0] = 0;
menuItems.time = time;
text = new String[1][4];
text[0][0] = "";
menuItems.text = text;
bgds = new Sprite[1][1];
bgds[0][0] = new Sprite(ImageLibrary.sun,0,0);
menuItems.bgds = bgds;
Dmenu.add(menuItems);
System.out.println("menus: " + MenuSelect.Dmenu.size());
/*BATTLE MENU*/
menuItems = new Menus(new int[1], new int[1], false, 0, new String[1][1], new Sprite[1][1]);
menuItems.dialog = true;
menuItems.sections = 1;
options = new int[1];
options[0] = 5;
menuItems.options = options;
time = new int[1];
time[0] = 0;
menuItems.time = time;
text = new String[1][5];
text[0][0] = "Attacks";
text[0][1] = "Party";
text[0][2] = "Items";
text[0][3] = "Tactics";
text[0][4] = "Close";
menuItems.text = text;
bgds = new Sprite[1][1];
bgds[0][0] = new Sprite(ImageLibrary.sun,0,0);
menuItems.bgds = bgds;
Dmenu.add(menuItems);
System.out.println("menus: " + MenuSelect.Dmenu.size());
} |
04ec6a46-cd8c-4d41-8093-d18fa976b9c6 | public static void setup(Menus menu){
RiftFrame.menuControl = false;
if(menu.dialog == false){
RiftFrame.menuControl = true;
for(int a=0;a<menu.options[0];a++){
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshes the variable so it does rewrite previous image
textTemp = new TextPoint("",0,0,new Color(255,255,255));
temp.x = -16;
temp.y = (360 - (menu.options[0] * 30)) + (a* 80); //finds mid and range than spaces it from middle
temp.img = ImageLibrary.selection;
textTemp.x = 10;
textTemp.y = temp.y + 40; //line it up with the image
textTemp.text = menu.text[0][a]; //gets the text for the
RiftGraphics.drawText.add(textTemp);
RiftFrame.imgs.add(temp);
}
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshing again
temp.x = -32;
temp.y = (360-(menu.options[0]*30)) + (selectPos* 80); //*23 is strange dont think it will always line up
temp.img = ImageLibrary.selected;
RiftFrame.imgs.set(((RiftFrame.imgs.size()) - menu.options[0]) + selectPos, temp); //draws the image twice once at 3, and selected one
}else{
if(menu.time[dialogNum] ==0){
RiftFrame.menuControl = true;
for(int b=0;b<menu.options[dialogNum];b++){
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshes the variable so it does rewrite previous image
textTemp = new TextPoint("",0,0,new Color(210,210,210));
temp.x = 358;
temp.y = (570 - (menu.options[dialogNum]* 40)) + (b*40);
temp.img = ImageLibrary.gSelection;
textTemp.x = 410;
textTemp.y = (temp.y + 20);
textTemp.text = menu.text[dialogNum][b];
RiftGraphics.drawText.add(textTemp);
RiftFrame.imgs.add(temp);
}
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshing again
if(menu.options[dialogNum] != 0 ){
temp.x = 374;
temp.y = (570 - (menu.options[dialogNum]* 40)) + (selectPos*40);
temp.img = ImageLibrary.gSelected;
RiftFrame.imgs.set(((RiftFrame.imgs.size()) - menu.options[dialogNum]) + selectPos, temp);
}
}else{
RiftFrame.startTime = true;
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshes the variable so it does rewrite previous image
textTemp = new TextPoint("",0,0,new Color(200,200,200));
temp.x = 4;
temp.y = 570;
temp.img = ImageLibrary.textDisplay;
textTemp.x = 14;
textTemp.y = 595;
textTemp.text = menu.text[dialogNum][0];
RiftFrame.imgs.add(temp);
RiftGraphics.drawText.add(textTemp);
if(RiftFrame.time > menu.time[dialogNum]){
RiftFrame.time = menu.time[dialogNum] + 1;
RiftFrame.menuControl = true;
for(int b=0;b<menu.options[dialogNum];b++){
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshes the variable so it does rewrite previous image
textTemp = new TextPoint("",0,0,new Color(210,210,210));
temp.x = 358;
temp.y = (570 - (menu.options[dialogNum]* 40)) + (b*40);
temp.img = ImageLibrary.gSelection;
textTemp.x = 400;
textTemp.y = (temp.y + 20);
textTemp.text = menu.text[dialogNum][b + 1];
RiftGraphics.drawText.add(textTemp);
RiftFrame.imgs.add(temp);
}
if(menu.options[dialogNum] != 0 ){
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshing again
temp.x = 374;
temp.y = (570 - (menu.options[dialogNum]* 40)) + (selectPos*40);
temp.img = ImageLibrary.gSelected;
RiftFrame.imgs.set(((RiftFrame.imgs.size()) - menu.options[dialogNum]) + selectPos, temp);
}
}
}
}
} |
4a7bace5-80e1-4f3a-b584-2ee7b8942f16 | public static void background(Menus menu){
for(int a=0;a<menu.bgds[dialogNum].length;a++){;
RiftFrame.bgs.add(menu.bgds[dialogNum][a]);
}
} |
d8afa942-4951-470b-b3c8-8dfbe0028df4 | public void paintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.WHITE);
g.setFont(new Font(null, Font.ROMAN_BASELINE, 20));
if (MenuSelect.menu == 1 || MenuSelect.menu ==2){
g.setFont(new Font(null, Font.ROMAN_BASELINE, 16));
}
for(int a=0; a< RiftFrame.bgs.size();a++){ //draws all the images added to the arraylist
img = RiftFrame.bgs.get(a);
//System.out.println("printing index: " + a + " at " + img.x + "," + img.y);
g.drawImage(img.img,img.x,img.y,null);
}
if (MenuSelect.play){
for (Floor a: LevelGen.tiles){
if (a.type == 0){
g.drawImage(ImageLibrary.rockyBG, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);//TODO -screenPos
} else if (a.type == 1){
g.drawImage(ImageLibrary.rockyUL, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 2){
g.drawImage(ImageLibrary.rockyU,a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 3){
g.drawImage(ImageLibrary.rockyUR, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 4){
g.drawImage(ImageLibrary.rockyR, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 5){
g.drawImage(ImageLibrary.rockyDR, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 6){
g.drawImage(ImageLibrary.rockyD, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 7){
g.drawImage(ImageLibrary.rockyDL, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 8){
g.drawImage(ImageLibrary.rockyL, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
} else if (a.type == 9){
g.drawImage(ImageLibrary.rockyB, a.x*32-LevelGen.mapPosX, a.y*32-LevelGen.mapPosY, null);
}
}
g.drawImage(MenuSelect.player.img[MenuSelect.player.d][0], 320, 352, null);
g.drawString(""+MenuSelect.player.x+", "+MenuSelect.player.y, 320, 352);
g.drawString(""+LevelGen.mapPosX+","+LevelGen.mapPosY, 350, 35);
}
for(int a=0; a< RiftFrame.imgs.size();a++){ //draws all the images added to the arraylist
img = RiftFrame.imgs.get(a);
//System.out.println("printing index: " + a + " at " + img.x + "," + img.y);
g.drawImage(img.img,img.x,img.y,null);
}
//System.out.println("amount of images: " + RiftFrame.imgs.size());
for(int a=0;a< drawText.size();a++){//draws all the texts given in the drawText ArrayList
text = drawText.get(a);
g.setColor(text.colour);
this.drawString(g, text.text, text.x, text.y -= g.getFontMetrics().getHeight());
}
RiftFrame.imgs.removeAll(RiftFrame.imgs); //resets the arraylists to prevent OOM exceptions
imageX.removeAll(imageX);
imageY.removeAll(imageY);
image.removeAll(image);
drawText.removeAll(drawText);
} |
32f053a4-7052-4ba7-acbe-a3fbe99903e3 | private void drawString(Graphics g, String text, int x, int y) {
for (String line : text.split("\n"))
g.drawString(line, x, y += g.getFontMetrics().getHeight());
} |
a231bcd8-1f8f-4a6a-a79b-88c9c424d685 | public static synchronized void playSound(final String sound){//used for playing sounds //TODO fix the directory so it plays sounds
new Thread(new Runnable(){//starts a new thread
public void run() {
try{
Clip clip = AudioSystem.getClip();//gets sound
AudioInputStream inputStream = AudioSystem.getAudioInputStream( //TODO there is a warning, we need to close() this somewhere
RiftFrame.class.getResourceAsStream("bin/sound/"+sound)
);
clip.open(inputStream);
clip.start();//plays sound
}catch(Exception e){
System.out.println("cannot parse input stream for FileIO when trying to play sound");
}
}
}).start();
} |
81e841ea-ac7a-4a25-8af4-d7083218bece | public void run() {
try{
Clip clip = AudioSystem.getClip();//gets sound
AudioInputStream inputStream = AudioSystem.getAudioInputStream( //TODO there is a warning, we need to close() this somewhere
RiftFrame.class.getResourceAsStream("bin/sound/"+sound)
);
clip.open(inputStream);
clip.start();//plays sound
}catch(Exception e){
System.out.println("cannot parse input stream for FileIO when trying to play sound");
}
} |
fe8e1110-581a-4eef-b3a6-d6be1ee3b478 | public Menus(int[] options, int[] time, boolean dialog, int sections, String[][] text, Sprite[][] bgds){
this.dialog = dialog;
this.sections = sections;
this.options= options;
this.time = time;
this.text = text;
this.bgds = bgds;
} |
018142a0-01d9-4b8d-bf77-e209df63f887 | public Land(float x, float y) throws SlickException{
super(x, y);
Image Land = new Image("Images/Land.png");
setGraphic(Land);
System.out.println("x= " + x + " " + "y= " + y);
depth = 0;
} |
67786fc2-8f11-48f9-96e0-726d4e9eb828 | public GameStateController() {
super("ZOMBIE ALPACALYPSE");
} |
73ece03f-f5f0-49e0-854c-b50fa7eb6931 | public void initStatesList(GameContainer container) throws SlickException {
addState(new Title(0,container));
addState(new GameWorld(1,container));
} |
1b9f2cdf-60ab-4982-b8df-ba8aa480ff5a | public static void initResources() throws SlickException
{
} |
86732e4d-4b15-4ad6-800f-f7f1c69b6887 | public void render(GameContainer arg0, StateBasedGame arg1, Graphics g)throws SlickException
{
g.setBackground(Color.white);
} |
fa6e7b46-1552-4f58-88ce-57dcf6789e9f | public static void main(String[] args) throws Exception
{
AppGameContainer app = new AppGameContainer(new GameStateController());
app.setDisplayMode(1024, 720, false);
app.setTargetFrameRate(144);
app.start();
} |
2d8cbf28-3cad-4faa-af01-1184c130b1c3 | public GameWorld(int id, GameContainer container) throws SlickException
{
super(id, container);
ME.keyToggleDebug = Input.KEY_1;
} |
82161c37-73a0-4d95-b1f3-4a78f095578b | @Override
public void init(GameContainer container, StateBasedGame game)throws SlickException
{
super.init(container, game);
add(new Land(0,0));
} |
1b13e996-9df7-462f-8de9-36440785d91f | public void update(GameContainer container, StateBasedGame game, int delta)throws SlickException
{
super.update(container, game, delta);
} |
387d4717-e8a0-43c0-9e93-b7e511cd2124 | @Override
public void render(GameContainer container, StateBasedGame game, Graphics g)throws SlickException
{
super.render(container, game, g);
g.setBackground(Color.white);
} |
48f396d6-5a58-46b0-9a82-b136d6889bd0 | public Title(int id, GameContainer container)
{
ME.keyToggleDebug = Input.KEY_1;
} |
fba15a87-c589-46ee-9bed-8f0f6397a92f | @Override
public void render(GameContainer container, StateBasedGame game, Graphics g)throws SlickException {
Image Title = new Image("Images/Logo.png");
Title.draw(0, 0);
g.setColor(Color.white);
g.setBackground(Color.black);
} |
02ba2cc7-3751-47d8-8daa-cbd4b7459c79 | @Override
public void update(GameContainer container, StateBasedGame sbg, int delta)throws SlickException
{
Input input = container.getInput();
if(input.isKeyPressed(input.KEY_ENTER))
{
sbg.enterState(1, new FadeOutTransition(), new RotateTransition());
}
} |
bd95eeff-dbe5-4d59-b80d-0ff19bd0829e | @Override
public int getID()
{
return 0;
} |
8e243473-d9db-4ce6-9c34-e9ca2a10e79e | @Override
public void init(GameContainer arg0, StateBasedGame arg1)throws SlickException {
} |
8922d949-920a-4944-b793-9e908cf887bb | Peao(boolean b, Posicao posicao) {
super(b, posicao);
} |
67f62017-f2f2-49e6-b9c4-a6acfb9da7f4 | public String getNome() {
return "Peao";
} |
428f53f0-018e-4952-b239-745654d6e13e | public boolean validaMovimento(Posicao posicao, boolean captura) {
super.validaTabuleiroMaximo(posicao);
switch (getSimbolo()){
case 'P':
if(captura == false){
if (this.posicao.y == 1 &&
(posicao.y - this.posicao.y == 1 ||
posicao.y - this.posicao.y == 2) &&
posicao.x == this.posicao.x){
return true;
}else if (this.posicao.y < 7 &&
posicao.y - this.posicao.y == 1 &&
posicao.x == this.posicao.x)
{
return true;
}
} else if (captura == true){
if (Math.abs(this.posicao.x - posicao.x) == 1 &&
Math.abs(this.posicao.y - posicao.y) == 1)
{
return true;
}
}
break;
case 'p':
if(captura == false){
if (this.posicao.y == 6 &&
(this.posicao.y - posicao.y == 1 ||
this.posicao.y - posicao.y == 2) &&
posicao.x == this.posicao.x)
{
return true;
} else if (this.posicao.y > 1 &&
this.posicao.y - posicao.y == 1 &&
posicao.x == this.posicao.x)
{
return true;
}
}else if (captura == true) {
if (Math.abs(this.posicao.x - posicao.x) == 1 &&
Math.abs(this.posicao.y - posicao.y) == 1 &&
captura == true)
{
return true;
}
}
break;
default:
break;
}
return false;
} |
0475e662-ed80-476d-ab30-f2f18d8e3af1 | public char getSimbolo() {
if (this.brancas == true){
return 'p';
}
else {
return 'P';
}
} |
b22b51fa-4ac9-47be-bba9-8559f67b33c6 | Rainha(boolean b, Posicao posicao) {
super(b, posicao);
} |
52e4ef2a-2159-45e9-94ee-ba2d4def710a | public String getNome() {
return "Rainha";
} |
6c2163c4-b7c6-4fbe-bd0b-4947d85345ed | public boolean validaMovimento(Posicao posicao, boolean captura) {
super.validaTabuleiroMaximo(posicao);
if (((Math.abs(this.posicao.y - posicao.y) == 0 || Math.abs(this.posicao.x - posicao.x) == 0))
|| Math.abs(this.posicao.y - posicao.y) == Math.abs(this.posicao.x - posicao.x))
{
return true;
}
return false;
} |
ed0562ec-7f78-4aa4-a044-a69c40ee2fe4 | public char getSimbolo() {
if (this.brancas == true){
return 'q';
}
else {
return 'Q';
}
} |
1b04d42d-6419-44fc-8e5c-cb94206c448e | Torre(boolean b, Posicao posicao) {
super(b, posicao);
} |
205e8ba6-1e6c-4f0b-b4ef-10f367576c34 | public char getSimbolo() {
if (this.brancas == true){
return 't';
}
else{
return 'T';
}
} |
61959fb3-d0db-454e-a39a-9faef59bf5ac | public String getNome() {
return "Torre";
} |
5dbb56bc-17dd-4b34-8c5e-076632647b56 | public boolean validaMovimento(Posicao posicao, boolean captura) {
super.validaTabuleiroMaximo(posicao);
if (Math.abs(this.posicao.y - posicao.y) == 0 || Math.abs(this.posicao.x - posicao.x) == 0)
{
return true;
}
return false;
} |
4b0bcdf4-a453-436f-a00f-547e6d6e900f | Cavalo(boolean b, Posicao posicao) {
super(b, posicao);
} |
630a59fc-5089-4567-94ba-5e6a4a5e6440 | public String getNome() {
return "Cavalo";
} |
5b21cd11-82b2-43ee-b194-583eee486eff | public boolean validaMovimento(Posicao posicao, boolean captura) {
super.validaTabuleiroMaximo(posicao);
if ((Math.abs(this.posicao.y - posicao.y) == 1 && Math.abs(this.posicao.x - posicao.x) == 2)
|| (Math.abs(this.posicao.y - posicao.y) == 2 && Math.abs(this.posicao.x - posicao.x) == 1))
{
return true;
}
return false;
} |
23049da2-f507-4aa9-9394-3b4042ca00e9 | public char getSimbolo() {
if (this.brancas == true){
return 'h';
}
else {
return 'H';
}
} |
d2cd968b-98ee-4843-b327-300255a6cf19 | public Peca(boolean brancas, Posicao posicao)
{
this.brancas = brancas;
this.setPosicao(posicao);
} |
ef3a5ca1-87fe-438f-8bc4-2e8c909b5338 | public Posicao getPosicao(){
return posicao;
} |
9472e334-0c39-456f-9574-45198836990f | public boolean branca()
{
return this.brancas;
} |
782b16c1-fec2-4459-8fd8-b8ca2af411af | public final void setPosicao(Posicao posicao){
this.posicao = posicao;
} |
8f2b2808-2801-4f40-aa62-866fb1a03db1 | public abstract String getNome(); |
3fb5cfd8-00b4-4f89-935f-e295c58daee4 | public abstract boolean validaMovimento(Posicao posicao, boolean captura); |
1881a3ff-3f0d-4713-98c9-88aecd6de5ee | public abstract char getSimbolo(); |
2706c266-bb2d-40b4-ba70-26bb77e75c98 | protected boolean validaTabuleiroMaximo( Posicao posicao){
if (posicao.x > TAB_LINHA_SUPERIOR || posicao.y > TAB_LINHA_SUPERIOR || posicao.x < TAB_LINHA_INFERIOR || posicao.y < TAB_LINHA_INFERIOR) {
return true;
}
return false;
} |
7b891fba-ca7b-43c0-9207-a6a0fe0db819 | public Peca getPecaMovida() {
return pecaMovida;
} |
238542bb-807e-4904-ab29-da220663a7b4 | public Peca getPecaCapturada() {
return pecaCapturada;
} |
e6739ffb-6df1-4bd5-942c-a6b8fd87ee22 | public Posicao getOrigem() {
return origem;
} |
2fcdd4c1-9480-425b-a6da-e6ae2c522787 | public Posicao getDestino() {
return destino;
} |
41fc79de-4c69-4cfc-ad7a-54f461c71f82 | public Jogada(Peca pecaMovida, Peca pecaCapturada, Posicao origem, Posicao destino)
{
this.pecaMovida = pecaMovida;
this.pecaCapturada = pecaCapturada;
this.origem = origem;
this.destino = destino;
} |
8c3f9c25-d613-4c41-af52-d162d9a32972 | public static void main(String[] args) throws IOException, FileNotFoundException, ClassNotFoundException{
Jogo jogo = new Jogo();
} |
8511496b-3c53-4e5d-a548-2e0918b1a85b | public Tabuleiro(ArrayList<Peca> listaPecas) {
for (int x = 0; x < TAMANHO_TABULEIRO; x++) {
for (int y = 0; y < TAMANHO_TABULEIRO; y++) {
tabuleiro[x][y] = null;
}
}
for (Peca p : listaPecas) {
tabuleiro[p.getPosicao().x][p.getPosicao().y] = p;
}
} |
2193db26-504c-48b2-b352-32e16966d5c1 | public Peca getCasa(Posicao pos){
return tabuleiro[pos.x][pos.y];
} |
5c444d15-af7b-4069-97f7-7eb1275dc426 | public void setCasa(Peca peca, Posicao posPeca)
{
tabuleiro[posPeca.x][posPeca.y] = peca;
if (peca != null) peca.setPosicao(posPeca);
} |
e5fbd93a-4de9-47e6-b751-f5f178881a45 | public void desfazerJogada(Jogada jogada)
{
this.setCasa(jogada.getPecaMovida(), jogada.getOrigem());
this.setCasa(jogada.getPecaCapturada(), jogada.getDestino());
} |
e27daa9c-e2c6-4b87-832c-ae7e0c3ffca1 | public Movimento mover(Posicao origem, Posicao destino, boolean brancas)
{
Peca pecaOrigem = this.getCasa(origem);
Peca pecaDestino = this.getCasa(destino);
boolean captura = pecaDestino != null && pecaOrigem != null && pecaDestino.branca() != pecaOrigem.branca();
Movimento mov = null;
if (pecaOrigem == null)
{
mov = new Movimento(false, "Nāo existe peça na origem");
}
else if (this.existePecaNoCaminho(origem, destino))
{
mov = new Movimento(false, "Existe peca no caminho.");
return mov;
}
else if (pecaDestino != null && pecaDestino.branca() == pecaOrigem.branca())
{
mov = new Movimento(false, "A peça de destino é uma peça do mesmo lado");
return mov;
}
else if (pecaOrigem.validaMovimento(destino, captura) == false)
{
mov = new Movimento(false, "A peça escolhida nāo realiza esse movimento");
}
else if (brancas != pecaOrigem.branca())
{
mov = new Movimento(false, "A peça escolhida não é sua.");
}
else if (pecaDestino == null)
{
mov = new Movimento(true, "Peca movida.");
this.setCasa(pecaOrigem, destino);
this.setCasa(null, origem);
}
else if (pecaOrigem.validaMovimento(destino, true))
{
mov = new Movimento(true, "A peca \"" + pecaDestino.getSimbolo() + "\" foi capturada.");
this.setCasa(pecaOrigem, destino);
this.setCasa(null, origem);
mov.fim = pecaDestino.getNome().equals("Rei");
}
return mov;
} |
7d0e56ce-636f-43b6-af8a-ef37fa1389f9 | public void draw() {
// Linhas:
for(int x = 0; x < TAMANHO_TABULEIRO; x++){
System.out.println(" |---|---|---|---|---|---|---|---|");
System.out.print(TAMANHO_TABULEIRO - x + " |");
// Colunas:
for(int y = 0; y < TAMANHO_TABULEIRO; y++){
Posicao posT = new Posicao(y, x);
if(getCasa(posT) == null)
System.out.print(" |");
else
System.out.print(" " + getCasa(posT).getSimbolo() + " |");
}
System.out.println("");
}
System.out.println(" |---|---|---|---|---|---|---|---|");
System.out.println(" A B C D E F G H \n");
System.out.println("CMD: ");
} |
a3d6a1c9-cee5-4d77-9ac4-0bf69f05cb01 | public boolean existePecaNoCaminho(Posicao orig, Posicao dest)
{
//linha / coluna DESTINO
Posicao origem = new Posicao(orig);
Posicao destino = new Posicao(dest);
//DIAGONAL
if (origem.y != destino.y && origem.x != destino.x)
{
int dirX = destino.x > origem.x ? 1 : -1;
int dirY = destino.y > origem.y ? 1 : -1;
for (int i = 1; i < Math.abs(destino.x - origem.x); i++)
{
int nextX = origem.x + i * dirX;
int nextY = origem.y + i * dirY;
Peca pecaCaminho = this.getCasa(new Posicao(nextX, nextY));
if (pecaCaminho != null)
{
return true;
}
}
return false;
}
//HORIZONTAL/VERTICAL
else if (origem.y == destino.y || origem.x == destino.x)
{
int dirX;
if (destino.x > origem.x)
dirX = 1;
else if (destino.x < origem.x)
dirX = -1;
else
dirX = 0;
int dirY;
if (destino.y > origem.y)
dirY = 1;
else if (destino.y < origem.y)
dirY = -1;
else
dirY = 0;
int distance = destino.x == origem.x ? destino.y - origem.y : destino.x - origem.x;
for (int i = 1; i < Math.abs(distance); i++)
{
int nextX = origem.x + i * dirX;
int nextY = origem.y + i * dirY;
Peca pecaCaminho = this.getCasa(new Posicao(nextX, nextY));
if (pecaCaminho != null)
{
return true;
}
}
return false;
}
return true;
} |
e09ec521-2907-4134-a230-08a219cf60c2 | Rei(boolean b, Posicao posicao) {
super(b, posicao);
} |
126e153d-f978-40e9-b34c-4c250f48f917 | public String getNome() {
return "Rei";
} |
934dfe05-6c00-46cb-9d7b-785c02d74a36 | public boolean validaMovimento(Posicao posicao, boolean captura) {
super.validaTabuleiroMaximo(posicao);
if (Math.abs(this.posicao.y - posicao.y) <= 1 && Math.abs(this.posicao.x - posicao.x) <= 1)
{
return true;
}
return false;
} |
e6715c62-0d49-43a7-8880-e60665411bf6 | public char getSimbolo() {
if (this.brancas == true){
return 'k';
}
else {
return 'K';
}
} |
87a1a9fd-d2a1-495e-bd4c-adac81e7994c | public Movimento(boolean validado,String mensagem){
this.validado = validado;
this.mensagem = mensagem;
} |
a4ae502f-9f02-456d-a595-50cfda2f71aa | public boolean getValidado(){
return validado;
} |
d9ffa2c6-16d7-4d3a-a37e-df85912edf1f | public String getMensagem(){
return mensagem;
} |
6912dfb0-739e-4602-be79-43315c45d522 | public Jogo() throws IOException, FileNotFoundException, ClassNotFoundException{
//Inicializa Tabuleiro
tabuleiro = new Tabuleiro(criaPecasPadrao());
loopJogo();
} |
b5ec3402-e772-401f-a2be-f56dbd602c03 | public ArrayList<Peca> criaPecasPadrao()
{
//true = brancas, false = pretas
pecas.add(new Torre(false, new Posicao(0, 0)));
pecas.add(new Torre(false, new Posicao(7, 0)));
pecas.add(new Torre(true, new Posicao(0, 7)));
pecas.add(new Torre(true, new Posicao(7, 7)));
pecas.add(new Bispo(false, new Posicao(2, 0)));
pecas.add(new Bispo(false, new Posicao(5, 0)));
pecas.add(new Bispo(true, new Posicao(2, 7)));
pecas.add(new Bispo(true, new Posicao(5, 7)));
pecas.add(new Rei(false, new Posicao(4, 0)));
pecas.add(new Rei(true, new Posicao(4, 7)));
pecas.add(new Rainha(false, new Posicao(3, 0)));
pecas.add(new Rainha(true, new Posicao(3, 7)));
pecas.add(new Cavalo(false, new Posicao(1, 0)));
pecas.add(new Cavalo(false, new Posicao(6, 0)));
pecas.add(new Cavalo(true, new Posicao(1, 7)));
pecas.add(new Cavalo(true, new Posicao(6, 7)));
pecas.add(new Peao(false, new Posicao(0, 1)));
pecas.add(new Peao(false, new Posicao(1, 1)));
pecas.add(new Peao(false, new Posicao(2, 1)));
pecas.add(new Peao(false, new Posicao(3, 1)));
pecas.add(new Peao(false, new Posicao(4, 1)));
pecas.add(new Peao(false, new Posicao(5, 1)));
pecas.add(new Peao(false, new Posicao(6, 1)));
pecas.add(new Peao(false, new Posicao(7, 1)));
pecas.add(new Peao(true, new Posicao(0, 6)));
pecas.add(new Peao(true, new Posicao(1, 6)));
pecas.add(new Peao(true, new Posicao(2, 6)));
pecas.add(new Peao(true, new Posicao(3, 6)));
pecas.add(new Peao(true, new Posicao(4, 6)));
pecas.add(new Peao(true, new Posicao(5, 6)));
pecas.add(new Peao(true, new Posicao(6, 6)));
pecas.add(new Peao(true, new Posicao(7, 6)));
return pecas;
} |
8a433dec-755d-49fc-947a-18d00ae1e4a6 | public void loopJogo() throws IOException, FileNotFoundException, ClassNotFoundException {
do {
//Redesenha a interface
display();
//Recebe e trata comandos do usuario
executaJogada();
} while(!this.finalizado);
System.out.println("\n\t TABULEIRO\n");
tabuleiro.draw();
String gameOver = "As pecas " + (!brancas ? "brancas" : "pretas") + " ganharam!";
System.out.println(gameOver);
} |
f6f8b93e-ded9-4b6d-8ca1-8ed12ae5ad1c | private void display() {
System.out.println("\n\t TABULEIRO\n");
tabuleiro.draw();
mensagem += "\nExecute o movimento das pecas " + (brancas ? "brancas " : "pretas ") + "(ex: a2a4)";
System.out.println(mensagem);
} |
511dc447-75a2-4bdd-83d3-f248401cabf7 | private Posicao[] parseMovimentoString(String movimento, boolean valid)
{
do {
if (movimento.length() == 4){
int x1 = row.indexOf(movimento.charAt(0));
int y1 = column.indexOf(movimento.charAt(1));
int x2 = row.indexOf(movimento.charAt(2));
int y2 = column.indexOf(movimento.charAt(3));
valid = (x1 != -1 && y1 != -1 && x2 != -1 && y2 != -1);
if (valid){
Posicao[] posicoes = new Posicao[2];
posicoes[0] = new Posicao(x1,y1);
posicoes[1] = new Posicao(x2,y2);
return posicoes;
}
}
return null;
} while (valid == false);
} |
fbebc3a8-c99a-4937-bdf1-1b06b1156866 | private void executaJogada() throws FileNotFoundException, IOException, ClassNotFoundException {
String move = leitor.nextLine();
if (move.compareToIgnoreCase("save") == 0)
{
FileOutputStream fos = new FileOutputStream("default.xdz");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(new Checkpoint(this.pecas, brancas));
oos.close();
mensagem = "Jogo Salvo! Digite \'load\' para carregar";
}
else if (move.compareToIgnoreCase("load") == 0)
{
try
{
FileInputStream fis = new FileInputStream("default.xdz");
ObjectInputStream ois = new ObjectInputStream(fis);
Checkpoint checkpoint = (Checkpoint)ois.readObject();
ArrayList<Peca> pecasSalvas = checkpoint.getPecas();
brancas = checkpoint.isBrancas();
ois.close();
this.tabuleiro = new Tabuleiro(pecasSalvas);
this.pecas = pecasSalvas;
mensagem = "Jogo recarregado";
}
catch (Exception e)
{
mensagem = "Arquivo não existe.";
}
}
else if (move.compareToIgnoreCase("undo") == 0 && jogadas.size() > 0 && !this.lastWasUndo)
{
int index = jogadas.size() - 1;
tabuleiro.desfazerJogada(jogadas.get(index));
jogadas.remove(index);
brancas = !brancas;
mensagem = "Jogada desfeita.";
this.lastWasUndo = true;
}
else if (parseMovimentoString(move, false) != null)
{
Posicao[] movimento = parseMovimentoString(move, false);
Peca pecaMovida = tabuleiro.getCasa(movimento[0]);
Peca pecaCapturada = tabuleiro.getCasa(movimento[1]);
Movimento movMsg = tabuleiro.mover(movimento[0], movimento[1], brancas);
if (movMsg.getValidado())
{
Jogada jogada = new Jogada(pecaMovida, pecaCapturada, movimento[0], movimento[1]);
jogadas.add(jogada);
this.lastWasUndo = false;
}
brancas = movMsg.getValidado() ? !brancas : brancas;
mensagem = movMsg.getMensagem();
this.finalizado = movMsg.fim;
}
else
{
mensagem = "Movimento invalido, exemplo correto: b1b5";
}
} |
dd13ae4e-0936-448f-8c52-c89ebf457abd | public ArrayList<Peca> getPecas() {
return pecas;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.