Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
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
Old Nov 17th, 2004, 8:08 AM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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.
__________________

tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:13 PM.

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