Murugan.com
Murugan Andezuthu Dharmaratnam

  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  PHP   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  



8086 Game Programming Collusion Detection


Home  > 8086  > 8086 Game Programming Collusion Detection 
       
;---------------------------------------------------------------------
; CollusionDetectionProc: Wrote this for a simple car racing game
;   I/P :
;       
;   Description : Collusion Routine checks to see if two rectangles
;                 have collided . 
;---------------------------------------------------------------------

CollusionDetectionProc proc near
 mov CollusionFlag,0     ; Set that the objects have not Collided

; Compare the Object 2 Rectangle (Left Top Point ) With
; Object 1 Rectangle 
  mov ax,Object2Left
  cmp ax,Object1Left
  jle  Object2NoCollusionLT
  mov ax,Object2Top
  cmp ax,Object1Top
  jle  Object2NoCollusionLT
  mov ax,Object2Left
  cmp ax,Object1Right
  jge  Object2NoCollusionLT
  mov ax,Object2Top
  cmp ax,Object1Bottom
  jge  Object2NoCollusionLT
  mov CollusionFlag,1     ; Set that the objects have Collided
Object2NoCollusionLT:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
; Compare the Object 2 Rectangle (Right Top Point ) With
; Object 1 Rectangle
  mov ax,Object2Right
  cmp ax,Object1Left
  jle  Object2NoCollusionRT
  mov ax,Object2Top
  cmp ax,Object1Top
  jle  Object2NoCollusionRT
  mov ax,Object2Right
  cmp ax,Object1Right
  jge  Object2NoCollusionRT
  mov ax,Object2Top
  cmp ax,Object1Bottom
  jge  Object2NoCollusionRT
  mov CollusionFlag,1     ; Set that the objects have Collided
Object2NoCollusionRT:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
; Compare the Object 2 Rectangle (Left Bottom Point ) With
; Object 1 Rectangle
  mov ax,Object2Left
  cmp ax,Object1Left
  jle  Object2NoCollusionLB
  mov ax,Object2Bottom
  cmp ax,Object1Top
  jle  Object2NoCollusionLB
  mov ax,Object2Left
  cmp ax,Object1Right
  jge  Object2NoCollusionLB
  mov ax,Object2Bottom
  cmp ax,Object1Bottom
  jge  Object2NoCollusionLB
  mov CollusionFlag,1     ; Set that the objects have Collided
Object2NoCollusionLB:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
; Compare the Object 2 Rectangle (Right Bottom Point ) With
; Object 1 Rectangle
  mov ax,Object2Right
  cmp ax,Object1Left
  jle  Object2NoCollusionRB
  mov ax,Object2Bottom
  cmp ax,Object1Top
  jle  Object2NoCollusionRB
  mov ax,Object2Right
  cmp ax,Object1Right
  jge  Object2NoCollusionRB
  mov ax,Object2Bottom
  cmp ax,Object1Bottom
  jge  Object2NoCollusionRB
  mov CollusionFlag,1     ; Set that the objects have Collided
Object2NoCollusionRB:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
;----------------
;Second Rectangle Collusion Detection 
;----------------
; Compare the Object 1 Rectangle (Left Top Point ) With
; Object 2 Rectangle
  mov ax,Object1Left
  cmp ax,Object2Left
  jle  Object1NoCollusionLT
  mov ax,Object1Top
  cmp ax,Object2Top
  jle  Object1NoCollusionLT
  mov ax,Object1Left
  cmp ax,Object2Right
  jge  Object1NoCollusionLT
  mov ax,Object1Top
  cmp ax,Object2Bottom
  jge  Object1NoCollusionLT
  mov CollusionFlag,1     ; Set that the objects have Collided
Object1NoCollusionLT:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
; Compare the Object 1 Rectangle (Right Top Point ) With
; Object 2 Rectangle
  mov ax,Object1Right
  cmp ax,Object2Left
  jle  Object1NoCollusionRT
  mov ax,Object1Top
  cmp ax,Object2Top
  jle  Object1NoCollusionRT
  mov ax,Object1Right
  cmp ax,Object2Right
  jge  Object1NoCollusionRT
  mov ax,Object1Top
  cmp ax,Object2Bottom
  jge  Object1NoCollusionRT
  mov CollusionFlag,1     ; Set that the objects have Collided
Object1NoCollusionRT:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
; Compare the Object 1 Rectangle (Left Bottom Point ) With
; Object 2 Rectangle
  mov ax,Object1Left
  cmp ax,Object2Left
  jle  Object1NoCollusionLB
  mov ax,Object1Bottom
  cmp ax,Object2Top
  jle  Object1NoCollusionLB
  mov ax,Object1Left
  cmp ax,Object2Right
  jge  Object1NoCollusionLB
  mov ax,Object1Bottom
  cmp ax,Object2Bottom
  jge  Object1NoCollusionLB
  mov CollusionFlag,1     ; Set that the objects have Collided
Object1NoCollusionLB:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
; Compare the Object 1 Rectangle (Right Bottom Point ) With
; Object 2 Rectangle
  mov ax,Object1Right
  cmp ax,Object2Left
  jle  Object1NoCollusionRB
  mov ax,Object1Bottom
  cmp ax,Object2Top
  jle  Object1NoCollusionRB
  mov ax,Object1Right
  cmp ax,Object2Right
  jge  Object1NoCollusionRB
  mov ax,Object1Bottom
  cmp ax,Object2Bottom
  jge  Object1NoCollusionRB
  mov CollusionFlag,1     ; Set that the objects have Collided
Object1NoCollusionRB:
;----------------
;Can Add A Jump Instuction Here Later For Speed 
;----------------
   ret
CollusionFlag   db 0
Object1Left     dw 0
Object1Top      dw 0
Object1Right    dw 0
Object1Bottom   dw 0
Object2Left     dw 0
Object2Top      dw 0
Object2Right    dw 0
Object2Bottom   dw 0
endp

hextoasc proc near                 ;AX input , si point result storage addres
        push ax bx cx dx si di bp es
        mov cx,00h
        mov bx,0ah
        hexloop1:
                mov dx,0
                div bx
                add dl,'0'
                push dx
                inc cx
                cmp ax,0ah
                jge hexloop1
                add al,'0'
                mov [si],al
        hexloop2:
                pop ax
                inc si
                mov [si],al
                loop hexloop2
                inc si
                mov al,'$'
                mov [si],al
                pop es bp di si dx cx bx ax
                ret
endp

Compile using: tasm filename.asm
link: tlink /t filename
8086 Assembly Lanaugage Clear the screen

8086 Assembly Lanaugage Program to Draw a box

8086 Assembly Writing Directly to Video Memory B800

8086 Assembly Causes a Delay in terms of 1 60 of a second Delay Macro

8086 Assembly Hello World Application

8086 Assembly Terminate the program and return to Dos prompt

8086 Assembly Language Wati for a keystroke or pause macro

8086 Assembly Language Delay Macro

8086 Game Programming Collusion Detection

8086 Assembly Game Collusion Detection Macro

8086 Assembly Lanuage Set the video display mode

8086 Write matrix of bytes to a memory game pogramming

8086 Assembly Language code procedure for delay

8086 Code Type String or Display String

8086 Assembly Language Convert from Hex to ascii

8086 Assembly Language Press Any Key to Continue Dialog

8086 Assembly Dialogbox or display a box with shadow in text mode

8086 Assembly cls clrscr or clear the screen

8086 assembly language read a string using standard input keyboard

8086 assembly language compare two strings strcmp procedure

8086 Assemly file io proc procedure to open a file

8086 Interrupt List

8086 Assembly Close FIle. Close a file opened for read write

8086 assembly language

8086 Assembly Language Sound Blaster Programming Play wav File

8086 assembly language program to play sound using pc speaker



  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  PHP   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  

Copyright 2009 @ Murugan Andezuthu Dharmaratnam