gregm@csd4.milw.wisc.edu (Gregory Mumm) (01/12/89)
I am a beginner when it comes to programing on the Amiga. I use Benchmark Modula-2 (A program which I highly recommend to anyone) and have a few questions. I am in the process of writing a very low-level A.I. program which is actually a very simple game (Two opposing space ships that shoot at each other) but have run into a few problems: 1) Question number one: how do you initialize, move, and detect collisions between sprites? (Geez! Is there anything ELSE you want?) I understand that the function GetSprite (from 'Sprites' Module) will initialize a sprite, but don't understand the details surrounding it. If I understand correctly the sprite is moved with the MoveSprite function (also found in the 'Sprites' Module), but again lack the details. Collision detection is done with the two functions SetCollision and DoCollision found in the 'Gels' Module I think. How do you set it up? How do you read a collision? Could someone hack out a little example for me or supply me some technical details/tips? I don't even care what the sprites look like--the art work can come latter. 2) This question is related to the last one: How do you read the Joystick port? The only manual I have is the Intuition manual (had to divert my money to tuition and couldn't afford the others--this is the primary reason why I don't know how to use sprites) and it doesn't say how to read it in there. I have noticed a module called 'GamePortDevice' in the Benchmark manual, but have a hard time reading it. 3) An unrelated question: Is it possible to do WriteStrings (etc) to the window of your choice? In the above program I open a full window (non-resizable) and attempt to do several WriteStrings. What happens is that they end up in the window the program was first run in. For example, if the program is started from the CLI then the CLI window gets all of the output while my window gets nothing printed in it. Is this an impossible task? Thanks for the help. I posted a similar message last week but only got one reply. (Sorry John, but I couldn't get through to you to ask you more questions.) Internet: gregm@csd4.milw.wisc.edu Uucp: uwvax!uwmcsd1!uwmcsd4!gregm Csnet: gregm%uwmcsd4@uwm Greg Mumm -- Internet: gregm@csd4.milw.wisc.edu Uucp: uwvax!uwmcsd1!uwmcsd4!gregm Csnet: gregm%uwmcsd4@uwm Greg Mumm
cs161agc@sdcc10.ucsd.EDU (John Schultz) (01/14/89)
In article <341@csd4.milw.wisc.edu> gregm@csd4.milw.wisc.edu (Gregory Mumm) writes: > > How do you read the Joystick port? The only manual I have is the Here is modula-2 example code to read the joystick. It reads the hardware directly, and is (was) legal when I wrote it (according to Bob). This is as fast and concise as I could get, without reverting to assembly... DEFINITION MODULE joystick; PROCEDURE readjoystick(VAR x,y : INTEGER; VAR buttonpressed : BOOLEAN; port : CARDINAL); END joystick. IMPLEMENTATION MODULE joystick; FROM SYSTEM IMPORT ADDRESS,SHIFT; FROM CIAHardware IMPORT ciaa,CIABITS; FROM CustomHardware IMPORT custom; CONST one = BITSET(1); TYPE bitsetptr = POINTER TO BITSET; VAR buttonloc : POINTER TO CIABITS; joydat : ARRAY[0..1] OF bitsetptr; j : BITSET; PROCEDURE readjoystick(VAR x,y : INTEGER; VAR buttonpressed : BOOLEAN; port : CARDINAL); BEGIN j := joydat[port]^; x := CARDINAL(SHIFT(j,-1) * one) - CARDINAL(SHIFT(j,-9) * one); y := CARDINAL(SHIFT(SHIFT(j,1) / j,-1) * one) - CARDINAL(SHIFT(SHIFT(j,1) / j,-9) * one); buttonpressed := NOT((6+port) IN buttonloc^); END readjoystick; BEGIN buttonloc := ADDRESS(ciaa^.pra); WITH custom^ DO joydat[0] := bitsetptr(joy0dat); joydat[1] := bitsetptr(joy1dat); END; END joystick. Hope this helps, John Schultz
cs161agc@sdcc10.ucsd.EDU (John Schultz) (01/14/89)
In article <48@sdcc10.ucsd.EDU> cs161agc@sdcc10.ucsd.edu.UUCP (John Schultz) writes:
[M2 joystick example deleted]
While posting this code to the net, I removed absolute addresses
(they're still there, but disguised). In doing so, I left out three
ADR statements, so the initialization code _should_ read:
BEGIN
buttonloc := ADDRESS(ADR(ciaa^.pra));
WITH custom^ DO
joydat[0] := bitsetptr(ADR(joy0dat));
joydat[1] := bitsetptr(ADR(joy1dat));
END;
END joystick.
Also, ADR must be imported from SYSTEM as well.