Page 2 of 2

Posted: Fri Mar 05, 2004 11:49 pm
by DriakTravo
That is actually quite hard to do (position cursor exactly to make the ship vanish).

I don't know why the ship disappears and can only come up with an inelegant solution, along the lines of:
Code:
If SpritePixelCollision(etc) <> 1
PlayerX + PlayerXS
PlayerY + PlayerYS
AddSmoke(etc)
Else ; klurge
PlayerX - 0.1
PlayerY - 0.1
EndIf
Yea, I guess the dissapearing ship issue is no biggy... especially if you have to TRY to make the ship dissapear.
Your code is pretty neat, BTW.
And thank you!

Posted: Fri Mar 05, 2004 11:57 pm
by Dreglor
sounds like you really need to update you directx there

Posted: Sat Mar 06, 2004 12:05 am
by Road Runner
DriakTravo,
Dont feel sorry. Other PB programs work but I haven't tried graphics/games type programs before. I ran your demo to compare with something else written in a different language. I thought the feedback might be useful to you.

Dreglor,
could well be a directX missing on the 2 PCs but the third one has DirectX8.1 installed and shows nothing but stars and mouse cursor.

Posted: Sat Mar 06, 2004 1:30 am
by blueznl
computers always manage to surprise me... refresh set to 85 produces 85 fps... refresh set to 100 produces 75 fps...

uh?

oh well, it works fine enough :-)

Posted: Sat Mar 06, 2004 1:58 am
by DriakTravo
computers always manage to surprise me... refresh set to 85 produces 85 fps... refresh set to 100 produces 75 fps...

uh?

oh well, it works fine enough
ROFL! Well I have 2 theories on why this might happen:

1. Do you have more processes running during the 2nd test?
2. Because your monitor is now a 100 refresh rate, it is eating more of your processor speed?

Otherwise.... I really don't know.... Computers are very random things. ;)

Posted: Sat Mar 06, 2004 3:44 am
by DriakTravo
I have seemed to run into some programming trouble. I am now programming the stuff to be able to make the player shoot bullets. But I can't seem to make the bullets appear in the right place... If someone could help me out with positioning the bullets in the right place when the player fires, I would greatly appriciate it. I will even put you in the game credits ;)

Here is a link to the updated code: http://www.1matthew.com/downloads/FollowDemo2.zip

Posted: Sat Mar 06, 2004 4:53 am
by J. Baker
The bullet in your "bul2" pic is not centered. This would solve the offset. Then go on from there. :D

Posted: Sat Mar 06, 2004 6:57 am
by Dare2
I am not that good with trig, so can't give you an immediate forumula, but I think this is what is required:

The guntips are points on a circle. The circle is centered on the vessel.

You need to know the radius of the circle described by the guntips, and their angles +/- in relation to the angle of the vessel. So if vessel angle is zero, based on centrepoint, then gun1 might be -10, gun2 +10

You need to calculate the X/Y of the guntip points based on the angle of the vessel and offset by their relative angles. Like working out where the spokes meet the rim of a wheel.

Then use these results instead of PlayerX/PlayerY for the first two args of each shoot function.

Sorry I can't give the algo for this right now, If need be I will dig it up and dust it off.

Hopefully you already have the maths, or somebody smarter than I can post it here.

Posted: Sat Mar 06, 2004 2:57 pm
by DriakTravo
Ok I updated my code so that it is acually possible to play.

Thank you for your suggestions, I have got the bullet now so that it shoots from the center of the ship.... I am not good in math yet to do the fancy calculations to make 2 bullets shoot where they are supposed to so if someone can help me out with that, I would appriciate it.

Also, anouther thing, once you stop shooting in the game and all of the bullets go offscreen (then they are deleted and there are no more elements in the list.) it still tries to run the procedure to update the bullets, even though I have:

Code: Select all

If CountList(Bullet()) > 0
Anyone know why this is happening?

You can download the new code from http://www.1matthew.com/downloads/FollowDemo2.zip

Thank you...

Posted: Sat Mar 06, 2004 3:41 pm
by Pupil
After you've deleted an element you really shouldn't use the list until you've called NextElement() again, as chances are that you'll have an empty list also you're wasing CPU time this way because you update the previous sprite one extra time for every element you delete...

So i would suggest something like this:

Code: Select all

Procedure UpdateSmoke()
  If CountList(Smoke()) <> 0
    ResetList(Smoke())
    NextElement(Smoke()) 
    Start3D()
    While NextElement(Smoke())
      Smoke()\X + Smoke()\XS-1
      Smoke()\Y + Smoke()\YS-1
      Smoke()\Size + 4
      Smoke()\Trans - 4
      If Smoke()\trans < 1
        DeleteElement(Smoke())
        Continue
      EndIf
      ZoomSprite3D(1,Smoke()\Size,Smoke()\Size)
      RotateSprite3D(1, Smoke()\R, 1) 
      DisplaySprite3D(1,Smoke()\X+ShakeX,Smoke()\Y+ShakeY,Smoke()\Trans)
    Wend
    RotateSprite3D(0,GetMouseAngle(),0)
    DisplaySprite3D(0,PlayerX-(SpriteWidth(0)/2)+ShakeX,PlayerY-(SpriteHeight(0)/2)+ShakeY)
    Stop3D()
  EndIf
EndProcedure

Procedure UpdateBullets()
  If CountList(Bullet()) > 0
    ResetList(Bullet())
    Start3D()
      While NextElement(Bullet())
        Bullet()\X + Bullet()\XS
        Bullet()\Y + Bullet()\YS
        If Bullet()\X > (1024+16) Or Bullet()\X < -16
          DeleteElement(Bullet())
          Continue
        EndIf
        If Bullet()\Y > (768+16) Or Bullet()\Y < -16
          DeleteElement(Bullet())
          Continue
        EndIf
        RotateSprite3D(PlayerWeapon,Bullet()\Angle,0)
        DisplaySprite3D(PlayerWeapon,Bullet()\X,Bullet()\Y)
        Bullet()\SC - 1
        If Bullet()\SC < 0
          Bullet()\SC = 0
        EndIf
        If Bullet()\SC = 0
          Bullet()\SC = Bullet()\SCS
          AddSmoke(Bullet()\X-10,Bullet()\Y-10,-Bullet()\XS,-Bullet()\YS)
        EndIf
      Wend
    Stop3D()
  EndIf
EndProcedure

Posted: Sun Mar 07, 2004 6:27 am
by DriakTravo
Thanks, I still need some help with positioning the bullets though.

Posted: Sun Mar 07, 2004 6:39 am
by DriakTravo
Nevermind, I figured it out. Thank you VERY much Dare2 and Pupil!!! :D :D

Posted: Sun Mar 07, 2004 6:56 am
by Dare2
Heya, glad you figured it out. :) I'm still battling with the sums. :?

Posted: Sun Mar 07, 2004 7:11 am
by DriakTravo
Ok! I have updated the link once again, the new code is at http://www.1matthew.com/downloads/FollowDemo2.zip . . . And everything WORKS now!!! THANK YOU so much EVERYONE for all your help so far. Please post what Frame Rate you are getting when you fire.

Thank you.

Posted: Sun Mar 07, 2004 7:58 am
by J. Baker
Very nice! Still 84 - 85 fps. :D