Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   Pong Game (http://www.programmingforums.org/showthread.php?t=1177)

PurpleMonkeyDW Nov 17th, 2004 8:53 AM

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.

tempest Nov 17th, 2004 9:08 AM

Variables "up" and "down" with values true and false attached to them. When it hits a boundary, the boundary that cant go anymore gets switched. And then you have a set of ifs that know what procedure to call based on these variables.


All times are GMT -5. The time now is 1:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC