Hi all,
I'm programming my version of the old game Wolfenstein 3D, using this scenario's View class:
http://www.greenfoot.org/scenarios/5619
For optimisation, I replaced this for loop:
by this:
There is only one big problem, look at this:
with for-loop:
my solution:
Can somebody help me? I don't know what I did wrong...
GreenfootImage texture = box.getTexture();
for (int wallY = 0; wallY <= 2 * height; wallY++)
{
double v = (double)wallY / (double)(2 * height);
double u = r.getImageOffset();
Color c = texture.getColorAt((int)(u *(texture.getWidth() - 1)), (int)(v*texture.getHeight() - 1)));
int y = img.getHeight()/2 - height + wallY;
if (y >= 0 && y < img.getHeight()) {
img.setColorAt((int)column, y, c);
}
}GreenfootImage texture = box.getTexture(); GreenfootImage stroke = new GreenfootImage(1,texture.getHeight()); stroke.drawImage(texture, x,0); stroke.scale(1, 2*height); int y = getImage().getHeight() /2 -stroke.getHeight() /2; getImage().drawImage(stroke, (int)column, y);


