![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 2
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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.
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|