thanks for that, any reason why my code to check wheter the ball hit the paddle or not isnt working ??/
comment ~ *****************
Name: <NAME>
SSN: <SSN>
Section: <SECTION>
Date: <DUE DATE>
Assignment: <ASSIGNMENT NUMBER>
Description: Input: Output:
~ *****************
.model small
.586
.stack 100h
.nolist
;*************************************************
;Includes
;*************************************************
include bios.inc
include constants.inc
.list
.data
ballpositionx word STARTX
ballpositiony word STARTY
paddlepositionx word PADDLEY
paddlepositiony word PADDLEX
ballvelocityy word STARTVELY
ballvelocityx word STARTVELX
brickarray db (ENDBRICKX-STARTBRICKX)*2 dup("*")
brickarray2 db (ENDBRICKX-STARTBRICKX)*2 dup ("*")
repeater word REPEATTIMES*300
.code
main proc
.startup
@Cls
@Setcsrpos,0,0
;initialize everything
mov ax,00DBh
mov di,0
neg ballvelocityx
InitLoop:
mov [brickarray+di],al
mov [brickarray2+di],al
inc di
cmp di,(ENDBRICKX-STARTBRICKX)*2
jne InitLoop
GameLoop:
@Cls
mov cx,((ENDBRICKX-STARTBRICKX)-1)*2
xor ax,ax
mov ax,VIDSEG
mov es,ax
lea si,brickarray
mov di,(160*STARTBRICKY)+STARTBRICKX*2
rep movsb
mov cx,(ENDBRICKX-STARTBRICKX-1)*2
xor si,si
lea si,brickarray2
mov di,(160*(STARTBRICKY+1))+STARTBRICKX*2
rep movsb
mov ax,160
mul paddlepositionx
push ax
mov ax,2
mul paddlepositiony
pop bx
add ax,bx
mov di,ax
mov ax,00DFH
mov cx,PADDLELEN
PaddleLoop:
mov es:[di],al
add di,2
dec cx
cmp cx,0
jne PaddleLoop
mov ax,160
mul ballpositiony
push ax
mov ax,2
mul ballpositionx
pop bx
add ax,bx
mov di,ax
mov ax,0C07h
mov es:[di],ax
BallMove:
cmp ballpositionx,0
jle NegXVel
cmp ballpositionx,79
jge NegXVel
cmp ballpositiony,0
jle NegYVel
cmp ballpositiony,24
jge NegYVel
jmp RegularBallMove
NegXVel:
neg ballvelocityx
jmp RegularBallMove
NegYVel:
neg ballvelocityy
jmp RegularBallMove
RegularBallMove:
mov ax,ballvelocityx
add ballpositionx,ax
mov ax,ballvelocityy
add ballpositiony,ax
GoOn:
xor ax,ax
mov ah, 00h
int 16h
cmp ah,01h
je done
cmp ah,48h
je PaddleUp
cmp ah,50h
je PaddleDown
cmp ah,4Dh
je PaddleLeft
cmp ah,4Bh
je PaddleRight
jmp GoBack
PaddleUp:
cmp paddlepositionx,13
jle CheckBall
dec paddlepositionx
jmp CheckBall
PaddleDown:
cmp paddlepositionx,23
jge CheckBall
inc paddlepositionx
jmp CheckBall
PaddleLeft:
cmp paddlepositiony,74
jge CheckBall
inc paddlepositiony
jmp CheckBall
PaddleRight:
cmp paddlepositiony,0
jle CheckBall
dec paddlepositiony
CheckBall:
mov ax,paddlepositiony
sub ax,ballpositiony
cmp ax,-1
je Negate
jmp GoBack
Negate:
neg ballvelocityy
mov ax,ballvelocityy
add ballpositiony,ax
GoBack:
dec repeater
cmp repeater,0
jne GameLoop
done:
@Cls
@Setcsrpos,0,0
.exit
main endp
end