|
Avatar |
|
/*
* JVirus is a PacMan clone, written in Java.
*
* Please read "http://jvirus.sourceforge.net/jvirus_licence.txt" for copyrights.
*
* The sourcecode is designed and created with
* Sun J2SDK 1.3 and Microsoft Visual J++ 6.0
*
* JVirus homepage: http://jvirus.sourceforge.net
*
* autor: Slawa Weis
* email: slawaweis@animatronik.net
*
*/
package org.game.JVirus;
import java.awt.Point;
/**
* Avatar class. Many variables are public for faster access.
*/
public class Avatar implements IFields
{
/**
* reference to the level.
*/
protected Matrix level = null;
/**
* mouth of avatar open or not
*/
public boolean eat_sequence = false;
/**
* running in the left or right direction
*/
public boolean move_direction = false;
/**
* whole game score
*/
public int gameScore = 0;
/**
* game score of current level
*/
public int gameScoreCurrentLevel = 0;
// public int gameDataBlocksCurrentLevel = 0;
/**
* whole game lifes
*/
public int gameLifes = 3;
/**
* game lifes of current level
*/
public int gameLifesCurrentLevel = 0;
/**
* position x of the avatar in the current level
*/
public int x = 0;
/**
* position y of the avatar in the current level
*/
public int y = 0;
/**
* last position x of the avatar in the current level
*/
public int lx = 0;
/**
* last position y of the avatar in the current level
*/
public int ly = 0;
/**
* constant for solved levels
*/
public static final int LEVEL_SOLVED = 0;
/**
* constant for can solve level
*/
public static final int LEVEL_CAN_SOLVE = 1;
/**
* must win first other level
*/
public static final int LEVEL_CAN_NOT_SOLVE = 2;
/**
* array of solved levels
*/
public int solvedLevels [] = null;
/**
* construct the Avatar. Bevor using it call setLevel(Matrix level, int x, int y).
*/
public Avatar()
{
solvedLevels = new int[Levels.getLevelCount()];
for(int i = 0; i < solvedLevels.length; i++)
solvedLevels[i] = LEVEL_CAN_NOT_SOLVE;
solvedLevels[0] = LEVEL_CAN_SOLVE;
solvedLevels[1] = LEVEL_CAN_SOLVE;
solvedLevels[2] = LEVEL_CAN_SOLVE;
}
/**
* set the current playing level
*/
public void setLevel(Matrix level, int x, int y)
{
this.x = this.lx = x;
this.y = this.ly = y;
this.level = level;
this.gameScoreCurrentLevel = 0;
// this.gameDataBlocksCurrentLevel = 0;
this.gameLifesCurrentLevel = 0;
}
/*
public void moveLeft()
{
move_direction = true;
last.setLocation(pos);
if(pos.x > 0 && Matrix.actionTyp[level.matrix[pos.y][pos.x-1]] != AT_EAT)
{
level.matrix[pos.y][pos.x] = EMPTY;
pos.x--;
// level.matrix[pos.y][pos.x] = JVirusMatrix.T3_AVATAR;
}
eat_sequence = !eat_sequence;
}
public void moveRight()
{
move_direction = false;
last.setLocation(pos);
if(pos.x < level.matrix[pos.y].length-1 && Matrix.actionTyp[level.matrix[pos.y][pos.x+1]] != AT_EAT)
{
level.matrix[pos.y][pos.x] = EMPTY;
pos.x++;
// level.matrix[pos.y][pos.x] = JVirusMatrix.T3_AVATAR;
}
eat_sequence = !eat_sequence;
}
public void moveUp()
{
last.setLocation(pos);
if(pos.y > 0 && Matrix.actionTyp[level.matrix[pos.y-1][pos.x]] != AT_EAT)
{
level.matrix[pos.y][pos.x] = EMPTY;
pos.y--;
// level.matrix[pos.y][pos.x] = JVirusMatrix.T3_AVATAR;
}
eat_sequence = !eat_sequence;
}
public void moveDown()
{
last.setLocation(pos);
if(pos.y < level.matrix.length-1 && Matrix.actionTyp[level.matrix[pos.y+1][pos.x]] != AT_EAT)
{
level.matrix[pos.y][pos.x] = EMPTY;
pos.y++;
// level.matrix[pos.y][pos.x] = JVirusMatrix.T3_AVATAR;
}
eat_sequence = !eat_sequence;
}
*/
}
|
Avatar |
|