Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A game in assembly

Status
Not open for further replies.

Lana1

MIS
May 6, 2012
1
0
0
Create a Game in assembly language That has an object that shoots at stars and moves horizantally using the mouse and shoots with left click.

What i have done till now:
org 100h

position db 23
my_position db 0
bullet db 12

MOV BX , 0B800H

MOV DS ,BX

MOV CX , 9


top: ADD SI , 16

MOV [SI] , "*"

loop top



myloop:
mov bullet,12
mov position,23



mov ch, 32
mov ah, 1
int 10h

mov ax,3
int 33h


mov ah,2
mov dh,24
shr cl,1
mov dl,cl
mov bh,0
int 10h


mov ah,0Ah
mov al,'!'
mov bh,0
mov cx,1
int 10h

mov ah,0Ah
mov al,' '
mov bh,0
mov cx,1
int 10h

mov ax, 3
int 33h
cmp bx,1
je click
jmp myloop

click:
mov my_position, cl
shr my_position,1
click2:
dec position
mov ah,2
mov dh,position
mov ah,2

mov dl,my_position
mov bh,0
int 10h

mov ah,0Ah
mov al,'*'
mov bh,0
mov cx,1
int 10h

mov ah,0Ah
mov al,' '
mov bh,0
mov cx,1
int 10h


add position , -1
add bullet , -1
jnz click2

jmp myloop
ret


But this code is a little slow and I can't seem to make a loop that makes a star disappear when it gets shooted. I would be grateful if someone helps me to fix this problem
 
When posting this type of queston it is helpful if you post Which Assembler (in your subjecy - as there are many), which hardware (pc, unix, etc) and which operating system w/ level/release.
 
LOL, I'm surprised it does anything at all on a current PC and doesn't crash it!

Looks like old DOS code, poking data directly into the CGA text screen memory; but the first thing I see wrong is starting with data at the ORG 100h entry point where I would expect to see code.
I'm also don't like the final RET without any CALLs (I could be wrong, but I thought there was a different mechanism for exiting back to the OS)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top