You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
7.0 KiB
Plaintext

package Main;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
public class Panel {
Image panel;
int i ;
int xPos,xSize,yPos,xSpd;
//Level Modelierungen
int[] yPos_level1= {0,12,12,11,11,10,10, 9, 9,-1,-1,
-1,-1, 9, 9, 9,10,10,11,11,12,
12,-1,-1,11,11,-1,-1,10,10,-1,
-1, 9, 9,-1,-1,-1, 9, 9,-1,-1,
-1,-1, 9, 9, 9,-1,-1,-1,-1,-1,
11,11,-1,-1,10,10,12,12, 7, 7,
7,-1,-1,-1,-1,-1, 8, 8, 7, 7,
-1,-1,-1,-1,-1,-1,11,11,-1,-1,
-1,-1,-1,12,12,10,10,-1,-1,-1,
-1,-1,11,11,12,12,12,12,12};
int[] yPos_level2= {0, 9, 9, 9,-1,-1, 8,10, 5,12, 5,
12, 9, 9, 9,-1, 5,12,-1,-1, 5,
-1,12,-1,-1,-1,-1,11,11,11,-1,
-1,-1,-1,10,10,10,-1,-1,-1,-1,
9, 9, 9,-1,12,12,12,-1, 8, 8,
8,-1,12,12,-1, 7, 7, 7,12,12,
12,12, 6, 6, 6,-1,12,12,-1, 5,
5, 5,-1,-1,-1,-1,-1,-1,-1,12,
12,12,12,12,12,-1,-1,-1,10,10,
10,-1,-1,-1, 9, 9,10,10,10};
int[] yPos_level3= {0, 7, 7, 7,11,11,11,-1,-1, 8, 8,
8,-1,-1,-1, 5, 5, 5,-1,-1, 8,
-1,-1,-1,-1,12,-1, 6,-1,-1, 9,
-1, 5, 5, 6, 6, 8, 8, 8, 9, 9,
-1,-1,-1, 6,12,-1, 9,-1,-1, 5,
5, 5, 9, 7, 6,12,-1,-1,-1,11,
6,12,12, 9, 5, 5,-1,-1,-1,-1,
-1,-1,-1, 9, 9, 9, 9,-1,-1,-1,
-1,12,12,-1, 6,12, 5,10,-1,-1,
-1, 5, 7, 7, 8, 8, 8, 8, 8};
int[] yPos_level4= {0,12,12,11,11,10,10,11,11,12,12,
11,12,12,11,11,12,12,10,10,19,
19,19,10,11,11,12,12,12,12,12,
12,11,11,11,10,10,10, 8,11, 8,
11,10,10,10, 9, 9, 8, 4,11, 4,
11, 4,11, 8, 8, 8, 4,11, 4,11,
4,12, 8, 8, 9, 9, 9,10,10,10,
11,11,11,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12};
int[] yPos_finalLevel= {0,12, 5,-1, 9,-1,-1,12, 5,-1,-1, 9,-1, 5,12};
State state;
Rectangle[] collisionarea;// Kollisionsvierecke f<>r die Roboter-Panel Kollisionen
int currentLevel;
public void init(GameContainer gc, State state,int currentLevel) throws SlickException {
// TODO Auto-generated method stub
this.state = state;
this.currentLevel = currentLevel;
panel = new Image ("Main/panel.png");
//initialwerte
xSize = 50;//breite eines Panels
yPos = 40;// h<>he eines Panels
xPos = 350;//Initial Position des ersten Panels
xSpd = 0;
//initiierung der einzelnen Kollisionsvierecke der jeweiligen Levels
switch(currentLevel){
case 1:
collisionarea = new Rectangle[yPos_level1.length];
for(int i = 1; i<yPos_level1.length;i++){
collisionarea = new Rectangle[yPos_level1.length];
//Errechnung nach Shema: xPosGesamt(leicht von rand weg,yPosGesamt aus Arrays+untere h<>lfte f<>r Draufsteh effekt, breite des Rechtecks, h<>he des Rechtecks
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level1[i]+20, 40, 20);
}break;
case 2:
collisionarea = new Rectangle[yPos_level2.length];
for(int i = 1; i<yPos_level2.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level2[i]+20, 40, 20);
}break;
case 3:
collisionarea = new Rectangle[yPos_level3.length];
for(int i = 1; i<yPos_level3.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level3[i]+20, 40, 20);
}break;
case 4:
collisionarea = new Rectangle[yPos_level4.length];
for(int i = 1; i<yPos_level4.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level4[i]+20, 40, 20);
}break;
case 5:
collisionarea = new Rectangle[yPos_finalLevel.length];
for(int i = 1; i<yPos_finalLevel.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_finalLevel[i]+20, 40, 20);
}break;
}
}
public void update(GameContainer gc, float _delta)throws SlickException {
// TODO Auto-generated method stub
xPos += xSpd* _delta;
//erstellung aller Panels durch Errechnung der Position
switch(currentLevel){
case 1:
for(int i = 1; i<yPos_level1.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level1[i]+20, 40, 10);
}
break;
case 2:
for(int i = 1; i<yPos_level2.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level2[i]+20, 40, 10);
}
break;
case 3:
for(int i = 1; i<yPos_level3.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level3[i]+20, 40, 10);
}
break;
case 4:
for(int i = 1; i<yPos_level4.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_level4[i]+20, 40, 10);
}
break;
case 5:
for(int i = 1; i<yPos_finalLevel.length;i++){
collisionarea[i]= new Rectangle(xPos+xSize*i+5, yPos*yPos_finalLevel[i]+20, 40, 10);
}
break;
}
}
public void render(GameContainer gc, Graphics g)throws SlickException {
// TODO Auto-generated method stub
switch(state.currentState){
case "start":
switch(currentLevel){
case 1:
for( i = 1; i<yPos_level1.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level1[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 2:
for( i = 1; i<yPos_level2.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level2[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 3:
for( i = 1; i<yPos_level3.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level3[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 4:
for( i = 1; i<yPos_level4.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level4[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
case 5:
for( i = 1; i<yPos_finalLevel.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_finalLevel[i]);
g.setColor(Color.cyan);
g.draw(collisionarea[i]);
}
break;
}
case "paused":
switch(currentLevel){
case 1:
for( i = 1; i<yPos_level1.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level1[i]);
}
break;
case 2:
for( i = 1; i<yPos_level2.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level2[i]);
}
break;
case 3:
for( i = 1; i<yPos_level3.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level3[i]);
}
break;
case 4:
for( i = 1; i<yPos_level4.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_level4[i]);
}
break;
case 5:
for( i = 1; i<yPos_finalLevel.length;i++){
panel.draw(xPos+xSize*i, yPos*yPos_finalLevel[i]);
}
break;
}
}
}
}