diff options
Diffstat (limited to 'projects/11/Pong/Ball.vm')
-rw-r--r-- | projects/11/Pong/Ball.vm | 427 |
1 files changed, 427 insertions, 0 deletions
diff --git a/projects/11/Pong/Ball.vm b/projects/11/Pong/Ball.vm index e69de29..b8154eb 100644 --- a/projects/11/Pong/Ball.vm +++ b/projects/11/Pong/Ball.vm @@ -0,0 +1,427 @@ +function Ball.new 0 +push constant 15 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +pop this 0 +push argument 1 +pop this 1 +push argument 2 +pop this 10 +push argument 3 +push constant 6 +sub +pop this 11 +push argument 4 +pop this 12 +push argument 5 +push constant 6 +sub +pop this 13 +push constant 0 +pop this 14 +push pointer 0 +call Ball.show 1 +pop temp 0 +push pointer 0 +return +function Ball.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function Ball.show 0 +push argument 0 +pop pointer 0 +push constant 1 +neg +call Screen.setColor 1 +pop temp 0 +push pointer 0 +call Ball.draw 1 +pop temp 0 +push constant 0 +return +function Ball.hide 0 +push argument 0 +pop pointer 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push pointer 0 +call Ball.draw 1 +pop temp 0 +push constant 0 +return +function Ball.draw 0 +push argument 0 +pop pointer 0 +push this 0 +push this 1 +push this 0 +push constant 5 +add +push this 1 +push constant 5 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Ball.getLeft 0 +push argument 0 +pop pointer 0 +push this 0 +return +function Ball.getRight 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 5 +add +return +function Ball.setDestination 3 +push argument 0 +pop pointer 0 +push argument 0 +push this 0 +sub +pop this 2 +push argument 1 +push this 1 +sub +pop this 3 +push this 2 +call Math.abs 1 +pop local 0 +push this 3 +call Math.abs 1 +pop local 1 +push local 0 +push local 1 +lt +pop this 7 +push this 7 +not +if-goto setDestination.Else0 +push local 0 +pop local 2 +push local 1 +pop local 0 +push local 2 +pop local 1 +push this 1 +push argument 1 +lt +pop this 8 +push this 0 +push argument 0 +lt +pop this 9 +goto setDestination.Endif0 +label setDestination.Else0 +push this 0 +push argument 0 +lt +pop this 8 +push this 1 +push argument 1 +lt +pop this 9 +label setDestination.Endif0 +push constant 2 +push local 1 +call Math.multiply 2 +push local 0 +sub +pop this 4 +push constant 2 +push local 1 +call Math.multiply 2 +pop this 5 +push constant 2 +push local 1 +push local 0 +sub +call Math.multiply 2 +pop this 6 +push constant 0 +return +function Ball.move 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Ball.hide 1 +pop temp 0 +push this 4 +push constant 0 +lt +not +if-goto move.Else0 +push this 4 +push this 5 +add +pop this 4 +goto move.Endif0 +label move.Else0 +push this 4 +push this 6 +add +pop this 4 +push this 9 +not +if-goto move.If0.Else0 +push this 7 +not +if-goto move.If0.Else0.Else0 +push this 0 +push constant 4 +add +pop this 0 +goto move.If0.Else0.Endif0 +label move.If0.Else0.Else0 +push this 1 +push constant 4 +add +pop this 1 +label move.If0.Else0.Endif0 +goto move.If0.Endif0 +label move.If0.Else0 +push this 7 +not +if-goto move.If0.If0.Else0 +push this 0 +push constant 4 +sub +pop this 0 +goto move.If0.If0.Endif0 +label move.If0.If0.Else0 +push this 1 +push constant 4 +sub +pop this 1 +label move.If0.If0.Endif0 +label move.If0.Endif0 +label move.Endif0 +push this 8 +not +if-goto move.Else1 +push this 7 +not +if-goto move.Else1.Else0 +push this 1 +push constant 4 +add +pop this 1 +goto move.Else1.Endif0 +label move.Else1.Else0 +push this 0 +push constant 4 +add +pop this 0 +label move.Else1.Endif0 +goto move.Endif1 +label move.Else1 +push this 7 +not +if-goto move.If1.Else0 +push this 1 +push constant 4 +sub +pop this 1 +goto move.If1.Endif0 +label move.If1.Else0 +push this 0 +push constant 4 +sub +pop this 0 +label move.If1.Endif0 +label move.Endif1 +push this 0 +push this 10 +gt +not +not +if-goto move.Else2 +push constant 1 +pop this 14 +push this 10 +pop this 0 +label move.Else2 +push this 0 +push this 11 +lt +not +not +if-goto move.Else3 +push constant 2 +pop this 14 +push this 11 +pop this 0 +label move.Else3 +push this 1 +push this 12 +gt +not +not +if-goto move.Else4 +push constant 3 +pop this 14 +push this 12 +pop this 1 +label move.Else4 +push this 1 +push this 13 +lt +not +not +if-goto move.Else5 +push constant 4 +pop this 14 +push this 13 +pop this 1 +label move.Else5 +push pointer 0 +call Ball.show 1 +pop temp 0 +push this 14 +return +function Ball.bounce 5 +push argument 0 +pop pointer 0 +push this 2 +push constant 10 +call Math.divide 2 +pop local 2 +push this 3 +push constant 10 +call Math.divide 2 +pop local 3 +push argument 0 +push constant 0 +eq +not +if-goto bounce.Else0 +push constant 10 +pop local 4 +goto bounce.Endif0 +label bounce.Else0 +push this 2 +push constant 0 +lt +not +push argument 0 +push constant 1 +eq +and +push this 2 +push constant 0 +lt +push argument 0 +push constant 1 +neg +eq +and +or +not +if-goto bounce.If0.Else0 +push constant 20 +pop local 4 +goto bounce.If0.Endif0 +label bounce.If0.Else0 +push constant 5 +pop local 4 +label bounce.If0.Endif0 +label bounce.Endif0 +push this 14 +push constant 1 +eq +not +if-goto bounce.Else1 +push constant 506 +pop local 0 +push local 3 +push constant 50 +neg +call Math.multiply 2 +push local 2 +call Math.divide 2 +pop local 1 +push this 1 +push local 1 +push local 4 +call Math.multiply 2 +add +pop local 1 +goto bounce.Endif1 +label bounce.Else1 +push this 14 +push constant 2 +eq +not +if-goto bounce.If1.Else0 +push constant 0 +pop local 0 +push local 3 +push constant 50 +call Math.multiply 2 +push local 2 +call Math.divide 2 +pop local 1 +push this 1 +push local 1 +push local 4 +call Math.multiply 2 +add +pop local 1 +goto bounce.If1.Endif0 +label bounce.If1.Else0 +push this 14 +push constant 3 +eq +not +if-goto bounce.If1.If0.Else0 +push constant 250 +pop local 1 +push local 2 +push constant 25 +neg +call Math.multiply 2 +push local 3 +call Math.divide 2 +pop local 0 +push this 0 +push local 0 +push local 4 +call Math.multiply 2 +add +pop local 0 +goto bounce.If1.If0.Endif0 +label bounce.If1.If0.Else0 +push constant 0 +pop local 1 +push local 2 +push constant 25 +call Math.multiply 2 +push local 3 +call Math.divide 2 +pop local 0 +push this 0 +push local 0 +push local 4 +call Math.multiply 2 +add +pop local 0 +label bounce.If1.If0.Endif0 +label bounce.If1.Endif0 +label bounce.Endif1 +push pointer 0 +push local 0 +push local 1 +call Ball.setDestination 3 +pop temp 0 +push constant 0 +return |