|
Hello, I got an error on the VM emulator.
it tells me "Out of segment space in Square.draw.7"
But I haven't the faintest idea of what that means....
To familiarize myself with Jack, I make a simple game where a square spawns at the top of the screen
and when it gets to the bottom , the square is destroyed.
I made my own Square class. it is similar to the one provided, but with some changes.
Can anyone help me figure out what this means so i can fix it? I can provide any details you need.
This is the function that it is messing up on...
method void draw(){
do Screen.setColor(true);
if (color){ //makes a filled in square
do Screen.drawRectangle(x, y, x+size, y+size);
}
else { //makes an outline of a square
do Screen.drawLine(x, y, x+size, y);
do Screen.drawLine(x+size, y, x+size, y+size);
do Screen.drawLine(x+size, y+size, x, y+size);
do Screen.drawLine(x, y+size, x, y);
}
return;
}
This is the vm code produced by the provided jackCompiler
function Square.draw 0
push argument 0
pop pointer 0
push constant 0
not
call Screen.setColor 1
pop temp 0
push this 3 //<----------------------this is the line that the vm emulator screams the error
if-goto IF_TRUE0
goto IF_FALSE0
label IF_TRUE0
push this 0
push this 1
push this 0
push this 2
add
push this 1
push this 2
add
call Screen.drawRectangle 4
pop temp 0
goto IF_END0
label IF_FALSE0
push this 0
push this 1
push this 0
push this 2
add
push this 1
call Screen.drawLine 4
pop temp 0
push this 0
push this 2
add
push this 1
push this 0
push this 2
add
push this 1
push this 2
add
call Screen.drawLine 4
pop temp 0
push this 0
push this 2
add
push this 1
push this 2
add
push this 0
push this 1
push this 2
add
call Screen.drawLine 4
pop temp 0
push this 0
push this 1
push this 2
add
push this 0
push this 1
call Screen.drawLine 4
pop temp 0
label IF_END0
push constant 0
return
|