Thread: Pong Game
View Single Post
Old Nov 17th, 2004, 7:53 AM   #1
PurpleMonkeyDW
Newbie
 
Join Date: Nov 2004
Posts: 2
Rep Power: 0 PurpleMonkeyDW is on a distinguished road
Hey! This is my very first post here so here goes. I'm working on a pong game in turbo assembler. I already have the two paddles working and stopping at the top and bottom of the screeen.

The problem I'm having is with a bouncing ball on the screen. Ok here's what I have so far:

main: mov ax, @data ;setting up the registers
mov ds, ax
mov es, ax

Beginning: mov cx, 16h

call IncColIncRow
;compare with bottom -->IncColDecRow
;compare with right -->DecColIncRow
;Compare both -->DecColDecRow


call IncColDecRow
;compare with top -->IncColIncRow
;compare with right -->DecColDecRow
;Compare both -->DecColIncRow

call DecColDecRow
;compare with top -->DecColIncRow
;compare with left -->IncColDecRow
;Compare both -->IncColIncRow

call DecColIncRow
;compare with bottom -->DecColDecRow
;compare with left -->IncColIncRow
;Compare both -->IncColDecRow

So I have 4 proceedures making the ball(a block) go in four diagonal directions, each with necessary delay, blank methods etc.
I just can't get my head around how to check if it's hitting which edge and calling the necessary proceedure without using a confusing amount of jump statements. I tried creating a new proceedure which checks the states of the ball(ie: comparing current column and row) and returning a number between 1 and 4 also but with no luck.

Can anyone suggest any sort of logic to doing this.
PurpleMonkeyDW is offline   Reply With Quote