GIT
/
REPO
/
FRED-BOY
Projects
/
cavedroid.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rename position -> pos
[cavedroid.git]
/
core
/
src
/
ru
/
deadsoftware
/
cavecraft
/
game
/
mobs
/
Pig.java
diff --git
a/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
b/core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
index 04a96f6b7d41ad9ced14bc919e584de9ee69f815..38eac46d69d9b70180df37400c86c70038bfbe34 100644
(file)
--- a/
core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
+++ b/
core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
@@
-4,17
+4,14
@@
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.game.GameWorld;
import ru.deadsoftware.cavecraft.misc.Assets;
import ru.deadsoftware.cavecraft.misc.Assets;
-import ru.deadsoftware.cavecraft.game.GameProc;
-public class Pig extends Mob{
+public class Pig extends Mob
{
public Pig(int x, int y) {
dir = MathUtils.random(1);
public Pig(int x, int y) {
dir = MathUtils.random(1);
- position = new Vector2(x, y);
- moveX = new Vector2(-1+dir*2, 0);
- moveY = new Vector2(0, 0);
+ pos = new Vector2(x, y);
+ move = new Vector2(-1 + dir * 2, 0);
width = 25;
height = 18;
canJump = false;
width = 25;
height = 18;
canJump = false;
@@
-23,36
+20,37
@@
public class Pig extends Mob{
@Override
public void changeDir() {
@Override
public void changeDir() {
- dir
=-dir+
1;
- move
X.set(-1+2*dir,0)
;
+ dir
= -dir +
1;
+ move
.x = -1 + 2 * dir
;
}
@Override
public void ai() {
if (MathUtils.randomBoolean(.0025f)) changeDir();
else if (MathUtils.randomBoolean(.0025f)) {
}
@Override
public void ai() {
if (MathUtils.randomBoolean(.0025f)) changeDir();
else if (MathUtils.randomBoolean(.0025f)) {
- if (move
X.x != 0f) moveX.setZero()
;
- else move
X.set(-1+2*dir, 0)
;
+ if (move
.x != 0f) move.x = 0
;
+ else move
.x = -1 + 2 * dir
;
}
}
- if (moveX.x != 0f) animation+=ANIM_SPEED; else animation=0;
- if (animation>=60 || animation<=-60) {
+ if (move.x != 0f) anim += ANIM_SPEED;
+ else anim = 0;
+ if (anim >= 60 || anim <= -60) {
ANIM_SPEED = -ANIM_SPEED;
}
}
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
ANIM_SPEED = -ANIM_SPEED;
}
}
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- Assets.pigSprite[0][1].setRotation(anim
ation
);
- Assets.pigSprite[1][1].setRotation(-anim
ation
);
+ Assets.pigSprite[0][1].setRotation(anim);
+ Assets.pigSprite[1][1].setRotation(-anim);
//back legs
//back legs
- Assets.pigSprite[1][1].setPosition(x
-4+(9-dir*9),y+
6);
+ Assets.pigSprite[1][1].setPosition(x
- 4 + (9 - dir * 9), y +
6);
Assets.pigSprite[1][1].draw(spriteBatch);
Assets.pigSprite[1][1].draw(spriteBatch);
- Assets.pigSprite[1][1].setPosition(x
+17-(9*dir),y+
6);
+ Assets.pigSprite[1][1].setPosition(x
+ 17 - (9 * dir), y +
6);
Assets.pigSprite[1][1].draw(spriteBatch);
//front legs
Assets.pigSprite[1][1].draw(spriteBatch);
//front legs
- Assets.pigSprite[0][1].setPosition(x
-4+(9-dir*9),y+
6);
+ Assets.pigSprite[0][1].setPosition(x
- 4 + (9 - dir * 9), y +
6);
Assets.pigSprite[0][1].draw(spriteBatch);
Assets.pigSprite[0][1].draw(spriteBatch);
- Assets.pigSprite[0][1].setPosition(x
+17-(9*dir),y+
6);
+ Assets.pigSprite[0][1].setPosition(x
+ 17 - (9 * dir), y +
6);
Assets.pigSprite[0][1].draw(spriteBatch);
//head & body
spriteBatch.draw(Assets.pigSprite[dir][0], x, y);
Assets.pigSprite[0][1].draw(spriteBatch);
//head & body
spriteBatch.draw(Assets.pigSprite[dir][0], x, y);
@@
-60,7
+58,7
@@
public class Pig extends Mob{
@Override
public Rectangle getRect() {
@Override
public Rectangle getRect() {
- return new Rectangle(pos
ition.x, position
.y, width, height);
+ return new Rectangle(pos
.x, pos
.y, width, height);
}
@Override
}
@Override
DEADSOFTWARE 2012-2025