gOver = true;
}
Input input = gc.getInput();
if (!playerC.dead && !playerC.dyin ) {
if(!playerC.attacking && input.isKeyDown(Input.KEY_1))
{
//bulowa
playerC.weaponWld = 1;
}
if(!playerC.attacking && input.isKeyDown(Input.KEY_2) && playerC.spearQ > 0)
{
//kopie
playerC.weaponWld = 2;
}
if(input.isKeyDown(Input.KEY_A) && !playerC.attacking)
{
//float oldX = playerC.x;
playerC.x += -0.08f * delta;
if (!checkCollison(playerC)) {
playerC.moving = true;
playerC.faceLeft = true;
} else
playerC.x += 0.08f * delta;
}
if(input.isKeyDown(Input.KEY_D) && !playerC.attacking)
{
//float oldX = playerC.x;
playerC.x += 0.08f * delta;
if (!checkCollison(playerC)) {
playerC.moving = true;
playerC.faceLeft = false;
} else
playerC.x -= 0.08f * delta;
}
if(input.isKeyDown(Input.KEY_W) && !playerC.attacking)
{
float oldY = playerC.y;
playerC.y -= 0.08f * delta;
if (!checkCollison(playerC))
playerC.moving = true;
else playerC.y = oldY;
}
if(input.isKeyDown(Input.KEY_S) && !playerC.attacking)
{
float oldY = playerC.y;
playerC.y += 0.08f * delta;
if (!checkCollison(playerC))
playerC.moving = true;
else playerC.y = oldY;
}
if(input.isKeyPressed(Input.KEY_M))
{
if (!muteMusic) {
muteMusic = true;
polka.stop();
}
else {
muteMusic = false;
polka.loop(1, 0.2f);
}
}
//TODO
if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
float mx = ((input.getMouseX() - scrWi/2)/xScale) + playerC.x ;
float my = ((input.getMouseY() - scrHe/2)/xScale) + playerC.y;
mouz.setXY(mx, my);
//System.out.println(" mxy = " + mx + "x" + my + " plxy = " + playerC.x + "x" + playerC.y);
//DasGame.playSound(15, DasGame.getDRX(playerC.x), DasGame.getDRX(playerC.y));
if (!playerC.attacking && playerC.weaponWld == 1) {
playerC.attacking = true;
playerC.inbatl = true;
playerC.agro = 0;
} else if (!playerC.attacking && playerC.weaponWld == 2 && playerC.spearQ > 0) {
playerC.attacking = true;
playerC.inbatl = true;
playerC.agro = 0;
}
checkCollison(mouz);
}
}
if (playerC.x < 0) playerC.x = 128*32;
if (playerC.x > 128*32) playerC.x = 0;
if (playerC.y < 0) playerC.y = 128*32;
if (playerC.y > 128*32) playerC.y = 0;
//Raspredelenie (48*xScale)
upRen.clear();
downRen.clear();
for (Entity obj : World.objecz) {
float wtdX = (obj.x - playerC.x) * xScale + scrWi/2;
float wtdY = (obj.y - playerC.y)* xScale + scrHe/2;
int xm = 64;
int xmm = 128;
if (wtdX >= ((128 * 32) - xm)*xScale ) wtdX -= (128 * 32)*xScale ;
if (wtdX < scrWi + ((xm - (128 * 32))*xScale) ) wtdX = wtdX + ((128 * 32)*xScale);
if (wtdY >= ((128 * 32) - xm)*xScale ) wtdY -= (128 * 32)*xScale ;
if (wtdY < scrHe+ ((xm - (128 * 32))*xScale) ) wtdY = wtdY + ((128 * 32)*xScale);
/*
if (wtdX >= -xm*xScale && wtdX < scrWi+xm*xScale
&& wtdY >= -xm*xScale && wtdY < scrHe+xm*xScale)
*/
/*
* if (obj.y <= playerC.y && obj.y > playerC.y - ((scrHe/1.75)/xScale) && wtdX >= -64*xScale && wtdX < scrWi+64*xScale) upRen.add(obj);
else if (obj.x > playerC.x - ((scrWi/1.75)/xScale) && obj.x < playerC.x + ((scrWi/1.75)/xScale) && obj.y < playerC.y + ((scrHe/1.75)/xScale)+32) downRen.add(obj);
*/
if (obj.y <= playerC.y && wtdY >= -xm*xScale && wtdX >= -xmm*xScale && wtdX < scrWi+xm*xScale) upRen.add(obj);
else if (wtdX >= -xmm*xScale && wtdX < scrWi+xm*xScale && wtdY < scrHe+xm*xScale) downRen.add(obj);
}
for (int i = 0; i < upRen.size(); i++) {
float min = upRen.get(i).y;
int imin = i;
for (int j = i; j < upRen.size(); j++) {
if (upRen.get(j).y < min) {
min = upRen.get(j).y;
imin = j;
}
}
if (i != imin) {
Entity temp = upRen.get(i);
upRen.set(i, upRen.get(imin));
upRen.set(imin, temp);
}
}
for (int i = 0; i < downRen.size(); i++) {
float min = downRen.get(i).y;
int imin = i;
for (int j = i; j < downRen.size(); j++) {
if (downRen.get(j).y < min) {
min = downRen.get(j).y;
imin = j;
}
}
if (i != imin) {
Entity temp = downRen.get(i);
downRen.set(i, downRen.get(imin));
downRen.set(imin, temp);
}
}
}
else if (!drawvoid && isIntrd1) {
if (!muteMusic) {
System.out.println("igsray!");
polka.fade(2000, 0, true);
muteMusic = true;
}
if (gOver && !gameEnded) {
Input input = gc.getInput();
if (input.isKeyDown(input.KEY_R)) restartgame();
}
//TODO ���������� ����