Space Warp!

Announce and discuss the progress of your various programming-related projects...programs, games, websites, tutorials, libraries...anything!

Moderators: Pete, Mods

User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

:shock: I got you demo $$$,
Ummm...I hope you don't mind a couple of suggestions...
Either:
  1. When the arrow keys are pressed, move the fighters more spaces in the directions, ie. Left arrow pressed go 5 spaces instead of 2.
  2. Use make mouse the primary control thing, and left button to fire, easy stuff to learn
These will make your ship move faster so you don't move a millimeter per second and be a sitting duck. :D

Now excuse me I have to go shovel (like a ton of snow we just got in that blizzard). Oh yeah, and Go Pats!! :wink:
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) Aye, my ship does go 5 pixals each press, I was going for speed, but letting off bing jerky looking,. I'll play around with diff speeds, the tug goes 2..

Corse theres a clever trick in blasting the tug,. when he comes up on you, start to move away with him leading the target, then blast him, hehe,..works really well... :D

Say, you tell me how to operate the QBX lib after I compile, I be more than glad to try the Mouse controll. :wink: , but I've never had much luck with it,..
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ok fine.

Make sure you have /l on the command line (at the end).
Now at the top of your program put:
REM $INCLUDE: 'QB.BI'

Now make two vars:
DIM inregs as RegType, outregs as RegType

Right after that put:
inregs.ax = 0
CALL INTERRUPT (&H33, inregs, outregs)

Ok now you have a choice of functions:
Do the second line of code above eveytime but change inregs.ax
0==>initializes the mouse (all ready did that above)
1==> I think shows the mouse cursor (ummm...block in screen 0, arrow in the others)
2==> I think hides the mouse cursor
3==> gets the status of the mouse (returns as outregs.bx for button [0 =no press, 1=left click, 2=right click, 3 = both click], outregs.cx for x coordinate, outregs.dx for y coordinate)

You can do others like make the cursor a small cross but theres a helpful tut somewhere on this site, I can't remember where.

It would be much help to create a function for yourself that takes care of this. (This works for me, you only really need 0 and 3=>initalization and get status).

Also I really don't like INKEY$ for real time programs, because it makes it choppy, like your game (no critizim intended), but thats just me.
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

All that you posted was mouse controll^,. :shock: mines much bigger than that.. like 80Lines of ASM...Machine code stuff.. I like yours thu! :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

So what did you mean for me to put?
The pseudocode?
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

No, is that really the mouse contoll? it calls the mouse and every thing? I'm just like shocked if it is, since the one I was using is 80Lines long, is all.
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Hmmm...80 lines of ASM....eighty lines of ASM....E I G H T Y Lines of ASM?!?!?!? :shock:
Well if it is or isn't it worked for me!
So thats it pal.
You just took the long route. :D
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

And they said Vics tuts where the best, oh well.. thanks, I see how I can use this, and if I like its a-go!! :D :wink:

Oh, and when I compile, it will work right?
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

If everything else works in QB when you compile this shouldn't be any different...Unless of course your working on XP (possible DOS compatibility issue), I'm not sure on that.
(I'm working on XP and it works when I run the program in QB, don't really know much about on how to make it .EXE)

Just try a sample program and see if it works...

By the way, this program has the poteintal to be cool if mouse could work.
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Yeah, and I'll c if I can't unlock that poteintal for SW's sake. :wink: Thanks for the input,. I'll read over it and see if I can compile it. :)
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ok, if you can create a function for the getmouse x,y,button stats as I have, then the pseudocode should be easy: Just replace the Inkey$ command but still have your fire but as the mouse button. As for the x,y, have your guy start at a single position, and just update the x,y coordinates of your ship to where the mouse is: easy as that. (you can also set boundries, ie. look at code below)
Here's some code:

Code: Select all

 REM $INCLUDE: 'QB.BI'
 DECLARE SUB getmouse (inregs AS ANY, outregs AS ANY, MouseButton, _MOUSEX, MouseY)
 DIM inregs AS RegType, outregs AS RegType
 inregs.ax=0
 CALL INTERRUPT (&H33, inregs, outregs)
 ship.x = 100: ship.y = 199
 SCREEN 13
 DO
   getmouse inregs, outregs, MouseButton, _MOUSEX, MouseY
   IF MouseButton = 1 THEN fire
   IF _MOUSEX > MaxX THEN _MOUSEX = MaxX
   IF _MOUSEX < MinX THEN _MOUSEX = MinX
   IF MouseY > MaxY THEN _MOUSEX = MaxY
   IF MouseY < MinY THEN MouseY = MinY 
   ship.x = _MOUSEX : ship.y = MouseY
   updateeverythingelse
   checkthings
   LINE ( 0 , 0 ) - (359, 199) , 0 , BF    'Like CLS but I don't like CLS (Too slow)
   Draweverything
   WAIT &H3DA, 8
LOOP
END

SUB getmouse (inregs AS RegType, outregs AS RegType, MB, MX, MY)
 inregs.ax = 3
 CALL INTERRUPT (&H33, inregs, outregs)
 MB = outregs.bx
 MX = outregs.cx
 MY = outregs.dx
END SUB

Hope that helps(that's just what I would have done) :D
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

I don't use CLS at all, or any other clear screen stile, lol,. I just mask.. How well that will work with the mouse I don't know yet :wink: , I'm going to see if it compiles first..
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Hope you liked my code... :D

It should work...hopefully...

Ummm...You can mask as long as you keep the mouse hidden (its hidden by default) I think...

The reason I don't like CLS, is because It clears the whole screen, and its slow because apparently it does more than clears the screen, look at help file...
"But...It was so beutifully done"
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

One more thing that code I put will run nice and smooth plus its very simple to understand :wink:. So mouse control could work wonders for your program.

Just thought I should say that.

One more thing what was with the 80 lines of ASM?
How can Mouse control be that complex?
"But...It was so beutifully done"
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

80 lines of ASM? Someone's either doing something wrong or lying to appear impressive.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

No you think? :D

I think It's just a sad result of being denied that grace that I have shown earlier in this thread.
:wink:
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:shock: , 80 Lines was a hyperboyl(can't spell, big word), but look at the code and you'll understand why I rounded the number so high...

Code: Select all

'-------------| START MOUSE PROGRAM (START COPYING HERE)--------------------

DEFINT A-Z
DECLARE SUB mouse (cx, dx, bx)
DECLARE SUB MousePointer (SW)
DIM SHARED a(9)                 'Set up array for code
DEF SEG = VARSEG(a(0))          'Get array segment (nnnn:    )
                                 '    (two 8 bit)
    FOR i = 0 TO 17                 'length of DATA to
       READ r                       'read
       POKE VARPTR(a(0)) + i, r     'into array/2 (nnnn:iiii) (one 8 bit)
    NEXT i                          'until 17

'**************************** Machine Code *********************************

DATA &HB8,&H00,&H00   :   ' mov  AX,[n]       [Swap code-(L),(H)] in AX
DATA &H55             :   ' push BP           Save BP
DATA &H8B,&HEC        :   ' mov  BP,SP        Get BP to c Seg
DATA &HCD,&H33        :   ' int  33           Interrupt 33
DATA &H92             :   ' xchg AX,[reg]     [Swap code-reg] in AX
DATA &H8B,&H5E,&H06   :   ' mov  BX,[BP+6]    Point to (variable)
DATA &H89,&H07        :   ' mov  [BX],AX      Put AX in (variable)
DATA &H5D             :   ' pop  BP           Restore BP
DATA &HCA,&H02,&H00   :   ' ret  2            Far return

SCREEN 13
'****************************** Mouse set up ******************************
           
                CALL MousePointer(0)      'Reset mouse and
                CALL MousePointer(1)      'turn pointer on
                CALL MousePointer(3)      'Get coordinates

'****************************** P R O G R A M ******************************
DO           'Put your code here
CALL mouse(cx, dx, bx)
LOCATE 1, 1: PRINT dx; cx; bx

LINE (50, 50)-(80, 70), 15, B
IF bx = 1 THEN
IF dx > 50 AND dx < 80 THEN
IF cx > 50 AND cx < 70 THEN
LOCATE 2, 1: PRINT "You clicked the box. Press. Esc."
END IF
END IF
END IF

LOOP UNTIL INKEY$ = CHR$(27) 'Stop your code here
END


'-------------------| THE END (Cut here)|--------------------------

SUB mouse (cx, dx, bx)
         
           POKE VARPTR(a(4)), &H92           'Swap code,Get CX setup
          CALL absolute(cx, VARPTR(a(0)))     'Run Code
            '  cx = cx / 8                     'Adjust 25x80
           POKE VARPTR(a(4)), &H91           'Swap code,Get DX setup
          CALL absolute(dx, VARPTR(a(0)))     'Run Code
              dx = dx / 2                     'Adjust 25x80
           POKE VARPTR(a(4)), &H93           'Swap code,Get BX setup
          CALL absolute(bx, VARPTR(a(0)))     'Run Code

                                   'Note :
                                   'Remove the /8
                                   'for graphics modes.

END SUB

SUB MousePointer (SW)
         
           POKE VARPTR(a(0)) + 1, SW         'Swap code,Set AX = (SW)
          CALL absolute(c, VARPTR(a(0)))     'Run Code

                                          'Note:
                                             'SW = 0-reset
                                             'SW = 1-on
                                             'SW = 2-off
                                             'SW = 3-coordinates


END SUB
:roll: ,. this has a box to click in,.. but that only take 4-5 lines of the code,. :)

PS: The code you gave me Mit worked wounders, compiled and every thing, :D :D :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

:shock:

Your Welcome, glad to be of help. :D

Now your game should be a really good game (or at least much better lol :lol:)

I see what this guy did with the mouse, he used CALL absolute () which is a direct link to execute some ASM. You had to store the variable separtly(In the statement VARSEG) then execute the lines.

In what we used we took advantage of the QB library: "QB.BI" which people usualy just let it sit dusting inside their computer (not really 'dusting' but you get the idea). We used Call interrupt () which I believe in my 1 month understanding of ASM in QB (No seriously I haven't even heard of ASM until a month ago) is used to call on a function that that library has that does what you did in your code(I think, they also say that CALL interrupt () is being called a lot when we execute certain key words (like PRINT or LOCATE)).

Anyway thats my limited understanding of it, thats good enough for me (my doctrine: "If it works don't play with it", no pun intended). :D

Well good luck to you.

I decided that I was going to establish, yes thats right Z!re, establish a thing called :D Mit's Tip of the Post :D . *Hear intro music*. Ya! Tell me what you think.

-------------------------------------------------------------------------------------
------------------------:D Mit's Tip of the Post :D ----------------------------
This Post's Tip:
>>>ENTER key returns CHR$(13) to INKEY$
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:wink: Tip of the post, lol,.. that pretty cool, but I already knew CHR$(13) was the INKEY$ for Enter,. lol,. hopefuly some1 else will see that thu, I picked my knowledge of that up from source code hunting, which is boring mind.. lol,.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

thanks.

>> :D Mit's Tip of the Post :D <<
>Tip #3:
>>Mind your POKEing, it may hurt someone. Oww..
"But...It was so beutifully done"
Post Reply