@@ -88,9 +88,13 @@ public void setDefaultValues() {
8888
8989 public void setDefaultPosition () {
9090 //player position of player
91- gameManager .currentMap = 3 ;
92- worldX = GameManager .TILE_SIZE * 25 ;
93- worldY = GameManager .TILE_SIZE * 1 ;
91+ gameManager .currentMap = 0 ;
92+ worldX = GameManager .TILE_SIZE * 30 ;
93+ worldY = GameManager .TILE_SIZE * 21 ;
94+ //TODO remove later
95+ // gameManager.currentMap = 3;
96+ // worldX = GameManager.TILE_SIZE * 25;
97+ // worldY = GameManager.TILE_SIZE * 1;
9498 direction = "down" ;
9599 }
96100
@@ -288,31 +292,31 @@ public void update() {
288292 entityAttack ();
289293 }
290294 //You can't guard while attacking
291- else if (keyHandler .spacePressed ) {
295+ else if (keyHandler .isSpacePressed ) {
292296 guarding = true ;
293297 guardCounter ++;
294298
295299 }
296300 //to avoid moving the character without pressing buttons
297- else if (keyHandler .upPressed || keyHandler .downPressed ||
298- keyHandler .leftPressed || keyHandler .rightPressed || keyHandler .enterPressed ) {
301+ else if (keyHandler .isUpPressed || keyHandler .isDownPressed ||
302+ keyHandler .isLeftPressed || keyHandler .isRightPressed || keyHandler .isEnterPressed ) {
299303
300304 //use else if to avoid diagonal movement, if it's not needed, use just if
301- if (keyHandler .upPressed ) {
305+ if (keyHandler .isUpPressed ) {
302306 direction = "up" ;
303- } else if (keyHandler .downPressed ) {
307+ } else if (keyHandler .isDownPressed ) {
304308 direction = "down" ;
305- } else if (keyHandler .leftPressed ) {
309+ } else if (keyHandler .isLeftPressed ) {
306310 direction = "left" ;
307- } else if (keyHandler .rightPressed ) {
311+ } else if (keyHandler .isRightPressed ) {
308312 direction = "right" ;
309313 }
310314
311315 turnOnCollision ();
312316 //Check Event
313317 gameManager .eventHandler .checkEvent ();
314318 //Change the direction of player
315- if (!collisionOn && !keyHandler .enterPressed ) {
319+ if (!collisionOn && !keyHandler .isEnterPressed ) {
316320 switch (direction ) {
317321 case "up" -> worldY -= speed ;
318322 case "down" -> worldY += speed ;
@@ -322,13 +326,13 @@ else if (keyHandler.upPressed || keyHandler.downPressed ||
322326 spriteMovement ();
323327 }
324328 //To prevent sword swing when interact with events by enter press
325- if (keyHandler .enterPressed && !attackCanceled ) {
329+ if (keyHandler .isEnterPressed && !attackCanceled ) {
326330 gameManager .playSE (10 );
327331 attacking = true ;
328332 spriteCounter = 0 ;
329333 }
330334 attackCanceled = false ;
331- gameManager .keyHandler .enterPressed = false ;
335+ gameManager .keyHandler .isEnterPressed = false ;
332336 guarding = false ;
333337 guardCounter = 0 ;
334338 //Change the player's walk/attack sprites
@@ -348,7 +352,7 @@ else if (keyHandler.upPressed || keyHandler.downPressed ||
348352
349353 //Shoot projectTiles, if the previous tile is still on the screen,
350354 //you can't shoot next one
351- if (keyHandler .shootKeyPressed && !projectTile .alive
355+ if (keyHandler .isShootKeyPressed && !projectTile .alive
352356 && shootAvailableCounter == 30 && projectTile .haveResource (this )) {
353357 //Set default coord, direction, alive state and entity
354358 projectTile .set (worldX , worldY , direction , true , this );
@@ -495,7 +499,7 @@ private void interactMob(int mobIndex) {
495499 private void interactNpc (int npcIndex ) {
496500 //if index not 999 - player touches the npc
497501 if (npcIndex != playerIndex ) {
498- if (gameManager .keyHandler .enterPressed ) {
502+ if (gameManager .keyHandler .isEnterPressed ) {
499503 attackCanceled = true ;
500504 gameManager .npcList [gameManager .currentMap ][npcIndex ].speak ();
501505 }
@@ -571,7 +575,7 @@ private void takeObject(int index) {
571575 }
572576 //Obstacle
573577 else if (gameManager .object [gameManager .currentMap ][index ].type == TYPE_OBSTACLE ) {
574- if (keyHandler .enterPressed ) {
578+ if (keyHandler .isEnterPressed ) {
575579 attackCanceled = true ;
576580 gameManager .object [gameManager .currentMap ][index ].interact ();
577581 }
0 commit comments