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!

Assembly first person shooter....quick question

Status
Not open for further replies.

K1NDRED

Programmer
Nov 19, 2006
4
0
0
CA
I'm making a little shooter type game in assembly and I just need to know 2 thing.

1-How do I use the mouse so that the program detects when it is clicked on the screen(i.e. A target moving across the screen and when the user clicks on it, it explodes(explosion is an animation frame, dont worry about that...just the clicking detection so that the program changes frame))

2-Will the mouse cursor be visible(i.e. Game crossair)?
 
1-I thought all i needed was int 33h for this...?
2-As in draw it in the data segment?
 
If you're using a 16-bit assembler and linker then you are quite right, you do not need anything more than int33h. Further, it is very unlikely that you will have to draw the mouse cursor yourself. If you want a different mouse-cursor than the standard arrow, you can define your own pattern (16 by 16 dots, mask and drawn thing) and tell int033h, and it will handle everything else for you. This works in any standard VGA mode (and if you have int033h I assume you are in 16-bit world with standard VGA graphics).

What you can't do is change to non-standard screen-sizes and weird modes, nor can you have a coloured or animated mouse-cursor. For any of those things, you will have to write your own mouse-cursor drawing code. But even this is not too dreadful because int033h is still perfectly functional and can at least handle all hardware of talking to the mouse, and returning its coordinates - whatever the screen size.
 
oh ok so you are saying that int 33h will allow the detection of where the mouse is clicked.
But how would I use that to know when my character on the screen should explode?
Do I need to define coordinates on the character's head(for example) so that when the mouse click is detected on that part, it returns a certain value, that value is evaluated using a CMP statement and the answer will either make the explosion frame appear or nothing.
Is my logic correct?
 
Yes, you have to take the screen coordinates of your mouse click, turn them back into 'world' coordinates for your objects, then work out which game object that corresponds to.


--
 
You can do this at various different levels of perfectionism.

Lowest level, make sure your target is approximately square. You know where the four corners are, in screen coordinates (you must do! Otherwise you couldn't draw the thing!). Just use cmp instructions to check that the mouse click coordinates fall within the square.

Next level, your target is an odd shape. You may need to check whether the mouse coordinates fall within the square that bounds the shape, and then check that the particular pixel the user clicked on corresponds to part of the target. This isn't as bad as it sounds because if you're drawing odd-shaped targets you probably already have some sort of mask for masking out the background, and that mask will do fine for the comparison.

Super-level: you're writing a 3-d shoot-out, in which case you need to go and read Foley and van Dam or equivalent and learn all about conversions from world coordinates to screen coordinates and back again. But since assembly is much more suited to simple 2d shootouts than complex 3d stuff, I'd assume this isn't worth the effort. If you do want to write 3d shootouts, do it in a high level language first, and move selected portions to assembly if it turns out vital.

Good luck
 
My shape is actually a horizontal oval(Eric cartman's head from the TV show South Park) but I will use the lowest level because the 2 others need a lot of programming and I have a november 30th deadline

The thing is that my target is moving. Does that mean I have to increment each coordinate in synchronization with the delay of the animation?

And I dont know where the coordinates are because I just drew the picture in the Data segment and used LEA insctruction to display it

Code:
FRAME10	DB	'            _,$'
FRAME11 DB	'        _.-{__}-._$'
FRAME12 DB	'      .:-~~____~~-:.$'
FRAME13 DB	'     /_.-~~_  _~~-._\$'
FRAME14 DB	'    /~   / .\/. \   ~\$'
FRAME15 DB	'    |    \__/\__/    |$'
FRAME16 DB	'  .-\                /-.$'
FRAME17 DB	' /   ~._-.__--__.-_.~  \ $'
FRAME18 DB	' \~.  /~~~~~~~~~~~~\   / $'
FRAME19 DB	' /__)|       ~      |(__\$'
FRAME20 DB	'   \_________~________/$'
FRAME21 DB	'   --------------------$'
JTABLE1 DW	FRAME10,FRAME11,FRAME12,FRAME13,FRAME14,FRAME15,FRAME16,FRAME17,FRAME18,FRAME19,FRAME20,FRAME21

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top