Hello everyone, Im creating a pacman copy and everything seemed to be just fine. However, after I added the feature of pacman removing dots, the game starts to lag after pacman destroys roughly a half of the dots and when all dots are removed the lag is insane. By 'lag' I mean the loss of frames between movement (the movement isnt smooth anymore). The particular lines I added to pacman's class act(), after which lagg occured:
Whole pacman, MyWorld and Dot codes respectively:
if (isTouching(Dot.class)) {
removeTouching(Dot.class);
world.dec_dots_left();
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class pacman here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class pacman extends Mover
{
private MyWorld world;
private int img_timer;
private Direction next_direction;
public pacman(MyWorld world) {
this.world = world;
curr_direction = Direction.left;
setImage(MyWorld.pac_animations[3]);
}
public void act()
{
if (isTouching(Dot.class)) {
removeTouching(Dot.class);
world.dec_dots_left();
}
Dot dot = (Dot) getOneIntersectingObject(Dot.class);
if (dot != null) {
//world.dec_dots_left();
getWorld().removeObject(dot);
}
Direction dir = checkInput();
int prev_x = getX(), prev_y = getY();
// jeigu nuspaudziam rodykle, tai issaugom, kuria kryptim norim judet
if (dir != null && dir != curr_direction)
next_direction = dir;
// jei galim, tai judam
if (next_direction != null && can_move(next_direction))
curr_direction = next_direction;
if (can_move(curr_direction)) {
move(curr_direction);
UpdateAnim(getX() - prev_x, getY() - prev_y);
}
if (MyWorld.map[getY()/8][getX()/8] == 4) // PORTAL
setLocation(getX() == 7 ? 27*8 : 8, getY());
}
private Direction checkInput() {
if (Greenfoot.isKeyDown("up"))
return Direction.up;
else if (Greenfoot.isKeyDown("right"))
return Direction.right;
else if (Greenfoot.isKeyDown("down"))
return Direction.down;
else if (Greenfoot.isKeyDown("left"))
return Direction.left;
return null;
}
private void UpdateAnim(int dx, int dy) {
turnTowards(getX()+dx, getY()+dy);
img_timer = (img_timer + 1) % 9;
// imam modulo is 9, nes viso animacija keisim 9 kartus (ratu)
// viso animaciju 5, tai keisim tokiu principu: 0 1 2 3 4 3 2 1 0
setImage(MyWorld.pac_animations[4-Math.abs(4-img_timer)]);
//setImage(MyWorld.pac_animations[Math.abs(img_timer - 2*(img_timer / 5 + img_timer % 5))]);
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* @author
* @version
*/
public class MyWorld extends World
{
/* FIELDS */
/* drawings */
public static final GreenfootImage ghost_anim[][][] = new GreenfootImage[4][4][2]; // ghost, direction, animation
public static final GreenfootImage pac_animations[] = new GreenfootImage[5];
public static final GreenfootImage dot_img[] = new GreenfootImage[2];
private Color c = new Color(255,185,175); // dot color
/* movers */
private pacman pacmanas;
private Blinky blinky;
private Pinky pinky;
private Inky inky;
private Clyde clyde;
private int dots_left, curr_maze;
public static final int[][] map = {
// -1 -> base entrance, 0 -> over the map, 1 -> wall, 2-> good, 3 -> silver dots, 4 -> portal
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1},
{ 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1},
{ 1, 3, 1, 0, 0, 1, 2, 1, 0, 0, 0, 1, 2, 1, 1, 2, 1, 0, 0, 0, 1, 2, 1, 0, 0, 1, 3,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, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1},
{ 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1},
{ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1},
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
/* METHODS */
public MyWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
// 28*8, 36*8
super(224, 288, 1, false);
Greenfoot.start();
build_maze(); // set background image
draw_dots();
add_dots(); // add dots to the world
draw_movers(); // fulfill ghost_anim and pac_animations arrays
SpawnPacman(); // spawns pacman to the world
SpawnGhosts(); // spawns ghost to the world
}
private void add_dots() // adds dots
{
for (int y=0; y<map.length; y++) {
for (int x=0; x<map[0].length; x++) {
int m = map[y][x];
Actor new_dot = null;
if (m == 2) // dot
new_dot = new Dot(false);
else if (m == 3)
new_dot = new Dot(true); // silver dot
if (new_dot != null) {
addObject(new_dot, 4 + x * 8, 4 + y * 8);
dots_left++;
}
}
}
}
private void SpawnPacman() {
pacmanas = new pacman(this);
addObject(pacmanas, 14*8, 4+26*8); // add pacman to the world
}
private void SpawnGhosts() {
/*
addObject(geist[0], 14*8, 4+14*8);
addObject(geist[1], 14*8, 4+17*8);
addObject(geist[2], 12*8, 4+17*8);
addObject(geist[3], 16*8, 4+17*8); */
draw_ghosts();
blinky = new Blinky();
addObject(blinky, 14*8, 4+14*8);
pinky = new Pinky();
addObject(pinky, 14*8, 18*8);
inky = new Inky();
addObject(inky, 12*8, 18*8);
clyde = new Clyde();
addObject(clyde, 16*8, 18*8);
}
private void draw_ghosts() {
Color c = new Color(255, 255, 0);
int k = 0;
for (int h=0; h<ghost_anim[0][0].length; h++) for (int i=0; i<ghost_anim[0].length; i++) for (int j=0; j<ghost_anim.length; j++)
{
k = 0;
ghost_anim[j][i][h] = new GreenfootImage(14,14);
switch(j)
{
case 0: c = new Color(255, 0, 0); break;
case 1: c = new Color(255, 184, 255); break;
case 2: c = new Color(0, 255, 255); break;
case 3: c = new Color(255, 184, 81); break;
}
ghost_anim[j][i][h].setColor(c);
ghost_anim[j][i][h].drawLine(5,k,8,k); k++;
ghost_anim[j][i][h].drawLine(3,k,10,k); k++;
ghost_anim[j][i][h].drawLine(2,k,11,k); k++;
ghost_anim[j][i][h].drawLine(1,k,12,k); k++;
ghost_anim[j][i][h].drawLine(1,k,12,k); k++;
ghost_anim[j][i][h].drawLine(1,k,12,k); k++;
ghost_anim[j][i][h].drawLine(0,k,13,k); k++;
ghost_anim[j][i][h].drawLine(0,k,13,k); k++;
ghost_anim[j][i][h].drawLine(0,k,13,k); k++;
ghost_anim[j][i][h].drawLine(0,k,13,k); k++;
ghost_anim[j][i][h].drawLine(0,k,13,k); k++;
ghost_anim[j][i][h].drawLine(0,k,13,k); k++;
switch (h) //unten verschieden
{
case 0:
ghost_anim[j][i][h].drawLine(0,k,1,k);
ghost_anim[j][i][h].drawLine(3,k,5,k);
ghost_anim[j][i][h].drawLine(8,k,10,k);
ghost_anim[j][i][h].drawLine(12,k,13,k);
k++;
ghost_anim[j][i][h].drawLine(0,k,0,k);
ghost_anim[j][i][h].drawLine(4,k,5,k);
ghost_anim[j][i][h].drawLine(8,k,9,k);
ghost_anim[j][i][h].drawLine(13,k,13,k);
break;
case 1:
ghost_anim[j][i][h].drawLine(0,k,3,k);
ghost_anim[j][i][h].drawLine(5,k,8,k);
ghost_anim[j][i][h].drawLine(10,k,13,k);
k++;
ghost_anim[j][i][h].drawLine(1,k,2,k);
ghost_anim[j][i][h].drawLine(6,k,7,k);
ghost_anim[j][i][h].drawLine(11,k,12,k);
break;
}
ghost_anim[j][i][h].setColor(new Color(222, 222, 255)); //weiß
switch (i)
{
case 1:
k = 3;
ghost_anim[j][i][h].drawLine(4,k,5,k); ghost_anim[j][i][h].drawLine(10,k,11,k); k++;
ghost_anim[j][i][h].drawLine(3,k,6,k); ghost_anim[j][i][h].drawLine(9,k,12,k); k++;
ghost_anim[j][i][h].drawLine(3,k,6,k); ghost_anim[j][i][h].drawLine(9,k,12,k); k++;
ghost_anim[j][i][h].drawLine(3,k,6,k); ghost_anim[j][i][h].drawLine(9,k,12,k); k++;
ghost_anim[j][i][h].drawLine(4,k,5,k); ghost_anim[j][i][h].drawLine(10,k,11,k);
ghost_anim[j][i][h].setColor(new Color(33, 33, 255)); //blau
k=5;
ghost_anim[j][i][h].drawLine(5,k,6,k); ghost_anim[j][i][h].drawLine(11,k,12,k); k++;
ghost_anim[j][i][h].drawLine(5,k,6,k); ghost_anim[j][i][h].drawLine(11,k,12,k);
break;
case 2:
k = 4;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k); k++;
ghost_anim[j][i][h].drawLine(2,k,5,k); ghost_anim[j][i][h].drawLine(8,k,11,k); k++;
ghost_anim[j][i][h].drawLine(2,k,5,k); ghost_anim[j][i][h].drawLine(8,k,11,k); k++;
ghost_anim[j][i][h].drawLine(2,k,5,k); ghost_anim[j][i][h].drawLine(8,k,11,k); k++;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k);
ghost_anim[j][i][h].setColor(new Color(33, 33, 255)); //blau
k = 7;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k); k++;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k);
break;
case 3:
k = 3;
ghost_anim[j][i][h].drawLine(2,k,3,k); ghost_anim[j][i][h].drawLine(8,k,9,k); k++;
ghost_anim[j][i][h].drawLine(1,k,4,k); ghost_anim[j][i][h].drawLine(7,k,10,k); k++;
ghost_anim[j][i][h].drawLine(1,k,4,k); ghost_anim[j][i][h].drawLine(7,k,10,k); k++;
ghost_anim[j][i][h].drawLine(1,k,4,k); ghost_anim[j][i][h].drawLine(7,k,10,k); k++;
ghost_anim[j][i][h].drawLine(2,k,3,k); ghost_anim[j][i][h].drawLine(8,k,9,k); k++;
ghost_anim[j][i][h].setColor(new Color(33, 33, 255)); //blau
k = 5;
ghost_anim[j][i][h].drawLine(1,k,2,k); ghost_anim[j][i][h].drawLine(7,k,8,k); k++;
ghost_anim[j][i][h].drawLine(1,k,2,k); ghost_anim[j][i][h].drawLine(7,k,8,k);
break;
case 0:
k = 1;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k); k++;
ghost_anim[j][i][h].drawLine(2,k,5,k); ghost_anim[j][i][h].drawLine(8,k,11,k); k++;
ghost_anim[j][i][h].drawLine(2,k,5,k); ghost_anim[j][i][h].drawLine(8,k,11,k); k++;
ghost_anim[j][i][h].drawLine(2,k,5,k); ghost_anim[j][i][h].drawLine(8,k,11,k); k++;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k);
ghost_anim[j][i][h].setColor(new Color(33, 33, 255)); //blau
k = 1;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k); k++;
ghost_anim[j][i][h].drawLine(3,k,4,k); ghost_anim[j][i][h].drawLine(9,k,10,k);
break;
}
}
}
private void draw_pacman() // fulfill pac_animations[]
{
Color c = new Color(255, 255, 0);
int k=0;
for (int i=0; i<pac_animations.length; i++)
{
pac_animations[i] = new GreenfootImage(13,13);
pac_animations[i].setColor(c);
pac_animations[i].drawLine(5,0,7,0);
pac_animations[i].drawLine(3,1,9,1);
pac_animations[i].drawLine(3,11,9,11);
pac_animations[i].drawLine(5,12,7,12);
switch (i)
{
case 0:
pac_animations[i].drawLine(0,5,0,7);
pac_animations[i].drawLine(1,3,1,9);
pac_animations[i].drawLine(11,3,11,9);
pac_animations[i].drawLine(12,5,12,7);
pac_animations[i].fillRect(2,2,9,9);
break;
case 1:
k=2;
pac_animations[i].drawLine(2,k,10,k); k++;
pac_animations[i].drawLine(1,k,11,k); k++;
pac_animations[i].drawLine(1,k,11,k); k++;
pac_animations[i].drawLine(0,k,9,k); k++;
pac_animations[i].drawLine(0,k,7,k); k++;
pac_animations[i].drawLine(0,k,9,k); k++;
pac_animations[i].drawLine(1,k,11,k); k++;
pac_animations[i].drawLine(1,k,11,k); k++;
pac_animations[i].drawLine(2,k,10,k);
break;
case 2:
k=2;
pac_animations[i].drawLine(2,k,10,k); k++;
pac_animations[i].drawLine(1,k,10,k); k++;
pac_animations[i].drawLine(1,k,9,k); k++;
pac_animations[i].drawLine(0,k,7,k); k++;
pac_animations[i].drawLine(0,k,6,k); k++;
pac_animations[i].drawLine(0,k,7,k); k++;
pac_animations[i].drawLine(1,k,9,k); k++;
pac_animations[i].drawLine(1,k,10,k); k++;
pac_animations[i].drawLine(2,k,10,k);
break;
case 3:
k=2;
pac_animations[i].drawLine(2,k,10,k); k++;
pac_animations[i].drawLine(1,k,9,k); k++;
pac_animations[i].drawLine(1,k,7,k); k++;
pac_animations[i].drawLine(0,k,5,k); k++;
pac_animations[i].drawLine(0,k,4,k); k++;
pac_animations[i].drawLine(0,k,5,k); k++;
pac_animations[i].drawLine(1,k,7,k); k++;
pac_animations[i].drawLine(1,k,9,k); k++;
pac_animations[i].drawLine(2,k,10,k);
break;
case 4:
k=2;
pac_animations[i].drawLine(2,k,8,k); k++;
pac_animations[i].drawLine(1,k,7,k); k++;
pac_animations[i].drawLine(1,k,6,k); k++;
pac_animations[i].drawLine(0,k,5,k); k++;
pac_animations[i].drawLine(0,k,4,k); k++;
pac_animations[i].drawLine(0,k,5,k); k++;
pac_animations[i].drawLine(1,k,6,k); k++;
pac_animations[i].drawLine(1,k,7,k); k++;
pac_animations[i].drawLine(2,k,8,k);
break;
}
}
}
private void draw_movers() {
draw_pacman();
draw_ghosts();
}
private void draw_dots() {
int z = 0;
// casual dot
dot_img[0] = new GreenfootImage(2, 2);
dot_img[0].setColor(c);
dot_img[0].fill();
// silver dot
dot_img[1] = new GreenfootImage(8, 8);
f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); z++;
f(dot_img[1],1,z); f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); f(dot_img[1],6,z); z++;
f(dot_img[1],0,z); f(dot_img[1],1,z); f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); f(dot_img[1],6,z); f(dot_img[1],7,z); z++;
f(dot_img[1],0,z); f(dot_img[1],1,z); f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); f(dot_img[1],6,z); f(dot_img[1],7,z); z++;
f(dot_img[1],0,z); f(dot_img[1],1,z); f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); f(dot_img[1],6,z); f(dot_img[1],7,z); z++;
f(dot_img[1],0,z); f(dot_img[1],1,z); f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); f(dot_img[1],6,z); f(dot_img[1],7,z); z++;
f(dot_img[1],1,z); f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); f(dot_img[1],6,z); z++;
f(dot_img[1],2,z); f(dot_img[1],3,z); f(dot_img[1],4,z); f(dot_img[1],5,z); z++;
}
private void f(GreenfootImage img, int x, int y) {img.setColorAt(x,y,c);}
private void build_maze() {
setBackground(Integer.toString(curr_maze) + ".png");
curr_maze++;
}
public void dec_dots_left() { // decrement dots_left, because a dot has been eaten
if (--dots_left == 0)
level_finished();
}
private void level_finished() {
return;
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Dot here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Dot extends Actor
{
private boolean silver = false;
public Dot(boolean silver) {
this.silver = silver;
setImage(MyWorld.dot_img[silver ? 1 : 0]);
}
}
