throwing a sprite at a target help needed

Advanced game related topics
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

throwing a sprite at a target help needed

Post by Rook Zimbabwe »

OK so far I have been assisted with taking out a target in PB. But now I am stuck on another matter.

Starting at 0,0 I want to throw a sprite at a target where I mouseclick.

CODE EDITED... But it still won't go towards a target... just a diagonal line!

Code: Select all

Two versions of code are below
{{ EDIT: CODE UPDATED but it still won't go to a target! }}
Last edited by Rook Zimbabwe on Sat Jul 12, 2008 12:41 am, edited 1 time in total.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
IceSoft
Addict
Addict
Posts: 1702
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Post by IceSoft »

Will be more and more a 'Missile Command' style:

Code: Select all

; German forum: http://www.purebasic.fr/german/archive/viewtopic.php?t=1518&start=10 
; Author: ChaOsKid (updated for PB4.00 by blbltheworm) 
; Date: 07. July 2003 
; modified by Rook Zimbabwe (Ralph Dunn) 7 JULY 2008 (that is a weird coincidence!) 
; english by RZ as well (99%) 


; Pressing left mousebutton fires a shot in the direction of the mouse cursor 
Enumeration 
    #Head 
    #Body 
    #Bullet 
    #Cursor 
    #Target 
EndEnumeration 

Structure Player 
  x.f 
  y.f 
  hSIZE.l 
  Speedo.l 
  TrickSpeedo.l 
  Angle.l 
  GoalAngle.l 
EndStructure 

Structure Projectile 
  x.f 
  y.f 
  SpeedoX.f 
  SpeedoY.f 
  Angle.l 
  GoalAngle.l 
  Scalar.l 
  Dimmer.l 
EndStructure 

Structure target 
  x.f 
  y.f 
EndStructure 

Global NewList Projectile.Projectile() 
Global NewList Target.target() 

Procedure.l gATan(a.l, b.l) 
  Angle.l = Int(ATan(a/b)*57.2957795) 
  If b < 0 
    Angle + 180 
  EndIf 
  If Angle < 0 : Angle + 360 : EndIf 
  If Angle > 359 : Angle - 360 : EndIf 
  ProcedureReturn Angle 
EndProcedure 

Procedure.f gSin(Angle.l) 
   ; Eingabe: Angle ( 0 - 360 ) 
   ; Ausgabe: Sine with Angle 
   ProcedureReturn Sin(Angle*0.01745329) 
EndProcedure 

Procedure.f gCos(Angle.l) 
   ; Entry Angle ( 0 - 360 ) 
   ; Output: Cosine with Angle 
   ProcedureReturn Cos(Angle*0.01745329) 
EndProcedure 

Procedure NewBullet(x.f, y.f, SpeedoX.f, SpeedoY.f) 
  AddElement(Projectile()) 
  Projectile()\x = x 
  Projectile()\y = y 
  Projectile()\SpeedoX = SpeedoX 
  Projectile()\SpeedoY = SpeedoY 
  Projectile()\Scalar = 5 
EndProcedure 

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 
  MessageRequester("Error", "DirectX 7 Fail!", 0) 
  End 
EndIf 

wide = 800 
High = 600 

If OpenScreen ( wide, High,32,"Standard") = 0 
  MessageRequester("Error", "No screen could be Initialized...", 0) 
  End 
EndIf 

If InitSprite3D() = 0 
  MessageRequester("DirectX fail !", "Cannot open DirectX...", #PB_MessageRequester_Ok) 
  End 
EndIf 

LoadSprite(1011, "BLIP\body1.bmp",#PB_Sprite_Texture) 
LoadSprite(1012, "BLIP\head1.bmp",#PB_Sprite_Texture) 
LoadSprite(bullet, "BLIP\blip00.bmp",#PB_Sprite_Texture) 
LoadSprite(enemy, "BLIP\blip11.bmp",#PB_Sprite_Texture) 

Sprite3DQuality(#PB_Sprite3D_BilinearFiltering) 

CreateSprite3D(#Head, 1011) 
CreateSprite3D(#Body, 1012) 
CreateSprite3D(#Bullet, bullet) 
CreateSprite3D(#Target,enemy) 

LoadSprite(#Cursor, "BLIP\cursor0.bmp",#PB_Sprite_Memory) 

Player1.Player 
Player1\hSIZE = 16 ; was 16 
Player1\x = wide/2 - Player1\hSIZE 
Player1\y = High/2 - Player1\hSIZE 
Player1\Speedo = 2 ; was 2 
Player1\TrickSpeedo = 2 ; was 2 
Player1\Angle = 0 ; was 270 

Maus.Point 

targetflag = 1 

For y.l = 0 To 97 Step 32 
      For x.l = 0 To 800 Step 32 
         AddElement(target()) 
         target()\x = x 
         target()\y = y 
      Next 
   Next 

Repeat 
  ClearScreen(RGB(0,0,0)) 

  ExamineMouse() 
  ExamineKeyboard() 

  Maus\x = MouseX() - 16 
  Maus\y = MouseY() - 16 
  a.l = Maus\y - Player1\y 
  b.l = Maus\x - Player1\x 
  Player1\GoalAngle = gATan(a, b) 
  
  If KeyboardPushed(#PB_Key_Left) Or KeyboardPushed(#PB_Key_A) 
    Player1\Angle - Player1\TrickSpeedo 
  EndIf 
  If KeyboardPushed(#PB_Key_Right) Or KeyboardPushed(#PB_Key_D) 
    Player1\Angle + Player1\TrickSpeedo 
  EndIf 
  ; 
  If KeyboardPushed(#PB_Key_Up) Or KeyboardPushed(#PB_Key_W) 
    Player1\x + (gCos(Player1\Angle) * Player1\Speedo) 
    Player1\y + (gSin(Player1\Angle) * Player1\Speedo) 
  EndIf 
  If KeyboardPushed(#PB_Key_Down) Or KeyboardPushed(#PB_Key_S) 
    Player1\x - (gCos(Player1\Angle) * Player1\Speedo) 
    Player1\y - (gSin(Player1\Angle) * Player1\Speedo) 
  EndIf 
  
  If Player1\x > wide - 32 
    Player1\x = wide - 32 
  EndIf 
  If Player1\x < 0 
    Player1\x = 0 
  EndIf 
  If Player1\y > High - 32 
    Player1\y = High - 32 
  EndIf 
  If Player1\y < 0 
    Player1\y = 0 
  EndIf 
  
Start3D() 

  If MouseButton(1) 

    If Delaytime < 1 
      Delaytime = 9 ; was 10 THIS IS HOW FAST YOU FIRE 
      Speedo.l = 8 
      Lifetime.l = 8 ; was 33 
      SpeedoX.f = gCos(Player1\GoalAngle) 
      SpeedoY.f = gSin(Player1\GoalAngle) 
      
    NewBullet(Player1\x + Player1\hSIZE + SpeedoX * Lifetime, Player1\y + Player1\hSIZE + SpeedoY * Lifetime, SpeedoX * Speedo, SpeedoY * Speedo) 
    DisplaySprite3D(#Bullet, Int(Player1\x), Int(Player1\y) ) 
    
    EndIf 

  If Delaytime > 0 
    Delaytime - 1 
  EndIf 
EndIf 


    RotateSprite3D(#Head, Player1\Angle, 0) 
    DisplaySprite3D(#Head, Int(Player1\x), Int(Player1\y),200) 
    RotateSprite3D(#Body, Player1\GoalAngle, 0) 
    DisplaySprite3D(#Body, Int(Player1\x), Int(Player1\y)) ;, 80) ; was 20 

    ResetList(Projectile()) 
    While NextElement(Projectile()) 
      If Projectile()\x < 0 Or Projectile()\y < 0 Or Projectile()\x > wide Or Projectile()\y > High Or Projectile()\Dimmer < - 254 
        DeleteElement(Projectile()) 
      Else 
        If SpriteCollision(bullet, Projectile()\x,Projectile()\y, #Cursor, Maus\x, Maus\y) 
          DeleteElement(Projectile()) 
          Break
        EndIf 
        Projectile()\x + Projectile()\SpeedoX 
        Projectile()\y + Projectile()\SpeedoY 
        Projectile()\Scalar + 1 ; size to increase by 1 to 10 but 10 is HUGE 
        Projectile()\Dimmer - 4 ; rate of decay... 10 fast 1 slow (3 to 7 is good for fire BALANCED by scalar!) 
        Projectile()\Angle + 10 ; rotation try 3, 8, 12 and 48 
        ZoomSprite3D(#Bullet, Projectile()\Scalar, Projectile()\Scalar) 
        RotateSprite3D(#Bullet, Int(Projectile()\Angle), 0) 
        DisplaySprite3D(#Bullet, Int(Projectile()\x), Int(Projectile()\y) , Int(Projectile()\Dimmer)) 
      
      EndIf 
    Wend 
    
    ResetList(target()) 
    While NextElement(target()) 
        DisplaySprite3D(#Target, Int(target()\x), Int(target()\y) ) 
    Wend 
    ; *************************************************************************************** 
    ; check for collision {{THUNK OUT BY Ice-Soft}} mangeld by Rook Zimbabwe 
     ; *************************************************************************************** 
     ResetList(Projectile()) 
     While NextElement(Projectile()) 
         If Projectile()\x > 0 Or Projectile()\y > 0 Or Projectile()\x < wide Or Projectile()\y < High
          
               ForEach(target())
                  If SpriteCollision(bullet, Projectile()\x,Projectile()\y, enemy, target()\x, target()\y) 
               
                    DeleteElement(target()) 
                    DeleteElement(Projectile()) 
                    Break
                  EndIf 
                Next  
            EndIf 
     Wend 
 Stop3D() 


 DisplayTransparentSprite(#Cursor, Maus\x, Maus\y) 
  
  FlipBuffers() 
    
  If KeyboardPushed(#PB_Key_Escape) 
    Quit = 1 
  EndIf 

  Delay(3) 
Until Quit 
Belive! C++ version of Puzzle of Mystralia
Bug Planet
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

FIXED! by Rook Zimbabwe

EDIT:: CRAP!!! I didn''t refresh... well lets try IceSofts example!
EDIT/ edit:: Well IceSofts example will not kill the target if it is faded... mine shoots at the target

You are going to need a target sprite as well...

Code: Select all


; Pressing left mousebutton fires a shot in the direction of the mouse cursor
Enumeration
    #Head
    #Body
    #Bullet
    #Cursor
    #Target
EndEnumeration

Structure Projectile
  x.f
  y.f
 goalX.f
  goalY.f
  Angle.l
  SpeedoX.f
  SpeedoY.f
  GoalAngle.l
EndStructure

Global Dim TLOC(1)
Global NewList Projectile.Projectile()
Global Goalangle, SpeedoX.f, SpeedoY.f

Procedure.l gATan(a.l, b.l)
  Angle.l = Int(ATan(a/b)*57.2957795)
  If b < 0
    Angle + 180
  EndIf
  If Angle < 0 : Angle + 360 : EndIf
  If Angle > 359 : Angle - 360 : EndIf
  ProcedureReturn Angle
EndProcedure

Procedure.f gSin(Angle.l)
   ; Eingabe: Angle ( 0 - 360 )
   ; Ausgabe: Sine with Angle
   ProcedureReturn Sin(Angle*0.01745329)
EndProcedure

Procedure.f gCos(Angle.l)
   ; Entry Angle ( 0 - 360 )
   ; Output: Cosine with Angle
   ProcedureReturn Cos(Angle*0.01745329)
EndProcedure

Procedure NewBullet(x.f, y.f, goalX.f, goalY.f)
  AddElement(Projectile())
  Projectile()\x = x
  Projectile()\y = y
  Projectile()\goalx = goalx
  Projectile()\goaly = goaly
  Projectile()\SpeedoX = SpeedoX
  Projectile()\SpeedoY = SpeedoY
EndProcedure

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Error", "DirectX 7 Fail!", 0)
  End
EndIf

wide = 800
High = 600

If OpenScreen ( wide, High,32,"Standard") = 0
  MessageRequester("Error", "No screen could be Initialized...", 0)
  End
EndIf

If InitSprite3D() = 0
  MessageRequester("DirectX fail !", "Cannot open DirectX...", #PB_MessageRequester_Ok)
  End
EndIf

LoadSprite(#Cursor, "BLIP\cursor0.bmp",#PB_Sprite_Memory)
LoadSprite(1013, "BLIP\blip01.bmp",#PB_Sprite_Texture)
LoadSprite(#Target, "BLIP\disc1.bmp",#PB_Sprite_Memory)
Sprite3DQuality(#PB_Sprite3D_BilinearFiltering)

CreateSprite3D(#Bullet, 1013)

Maus.Point

TLOC(0) = 0
TLOC(1) = 0

Repeat
ClearScreen(RGB(0,0,0))

  ExamineMouse()
  ExamineKeyboard()
  a.l = Maus\y 
  b.l = Maus\x 
  
  GoalAngle = gATan(a, b)
  
  
  
  Maus\x = MouseX() - 16
  Maus\y = MouseY() - 16

Start3D()
  If TLOC(0) > 0
    If TLOC(1) > 0
        DisplayTransparentSprite(#Target, TLOC(0), TLOC(1) )
    EndIf
  EndIf
  If MouseButton(1)
  
  TLOC(0) = Maus\x
  TLOC(1) = Maus\y

    If Delaytime < 1
      Delaytime = 10 ; was 10 THIS IS HOW FAST YOU FIRE
      Speedo.l = 12
      Lifetime.l = 20 ; was 33
      SpeedoX = gCos(GoalAngle)
      SpeedoY = gSin(GoalAngle)
     
    NewBullet(0,0,SpeedoX, SpeedoY)
    DisplaySprite3D(#Bullet, Projectile()\x, Projectile()\y )
   
    EndIf

  If Delaytime > 0
    Delaytime - 1
  EndIf
EndIf

    ResetList(Projectile())
    While NextElement(Projectile())
      If Projectile()\x < 0 Or Projectile()\y < 0 Or Projectile()\x > wide Or Projectile()\y > High 
        DeleteElement(Projectile())
      Else
        Projectile()\x + Projectile()\SpeedoX
        Projectile()\y + Projectile()\SpeedoY
        Projectile()\Angle + 10 ; rotation try 3, 8, 12 and 48
        RotateSprite3D(#Bullet, Int(Projectile()\Angle), 0)
        DisplaySprite3D(#Bullet, Int(Projectile()\x), Int(Projectile()\y))
        EndIf
    Wend
    
    ; ***************************************************************************************
    ; check for collision {{THUNK OUT BY Ice-Soft}} mangeld by Rook Zimbabwe
     ; ***************************************************************************************
     ResetList(Projectile())
     While NextElement(Projectile())  
               ForEach(Projectile())
                  If Projectile()\x = Projectile()\goalx - 16 And Projectile()\y = Projectile()\goaly - 16 Or Projectile()\x = Projectile()\goalx +16 And Projectile()\y = Projectile()\goaly +16 Or Projectile()\x = Projectile()\goalx - 16 And Projectile()\y = Projectile()\goaly +16 Or Projectile()\x = Projectile()\goalx + 16 And Projectile()\y = Projectile()\goaly - 16
                    DeleteElement(Projectile())
                    Break
                  EndIf
                Next 
     Wend
 Stop3D() 

 DisplayTransparentSprite(#Cursor, Maus\x, Maus\y)
 
  StartDrawing( ScreenOutput())
    DrawText(370, 550, "ANGLE: "+Str(goalangle), RGB(255,255,255), RGB(0,0,0))
StopDrawing()
 
  FlipBuffers()

  If KeyboardPushed(#PB_Key_Escape)
    Quit = 1
  EndIf

  Delay(3)
Until Quit
OK 99% fixed... still got to make the projectile and target dissappear when intersect...

Details... :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

You getting a lot of inaccuracy on the targetting still.
I have done a little bit to address this, but atm am out of time, so I will do some more if I find time when I get back home .- (tonight hopefully.) ( Changing from direct bullet, mouse sprite points to a couple of different (non displayed ) sprites for collision testing )
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

Found time to have a bit of a play here..
I have used the IceSoft example code used above here.
For the bullets I have created a 2nd non displayed bullet of 1 x 1 pixel size which uses the projectile x,y coordinates for collisions testing.
For the sight collisions I have made a 2nd non displayed sprite with a size allowing the displayed bullets to appear to be entering the sighting cursor. I have disabled the displayed bullet zooming as this bit needs more work to get accuracy.
As I don't have a copy of your real cursor I have just created 1 in the form of a little scope sight...
Still not 100% accurate, but getting closer. ( there is a couple of points around the screen where the bullets will pass by the cursor still )

Code: Select all

; German forum: http://www.purebasic.fr/german/archive/viewtopic.php?t=1518&start=10 
; Author: ChaOsKid (updated for PB4.00 by blbltheworm) 
; Date: 07. July 2003 
; modified by Rook Zimbabwe (Ralph Dunn) 7 JULY 2008 (that is a weird coincidence!) 
; english by RZ as well (99%) 


; Pressing left mousebutton fires a shot in the direction of the mouse cursor 
Enumeration 
    #Head 
    #Body 
    #Bullet 
    #Cursor 
    #Target 
    #enemy1 
    #Bullet1 
    #bullet2
    #Cursor2
EndEnumeration 

Structure Player 
  x.f 
  y.f 
  hSIZE.l 
  Speedo.l 
  TrickSpeedo.l 
  Angle.l 
  GoalAngle.l 
EndStructure 

Structure Projectile 
  x.f 
  y.f 
  SpeedoX.f 
  SpeedoY.f 
  Angle.l 
  GoalAngle.l 
  Scalar.l 
  Dimmer.l 
EndStructure 

Structure target 
  x.f 
  y.f 
EndStructure 

Global NewList Projectile.Projectile() 
Global NewList Target.target() 

Procedure.l gATan(a.l, b.l) 
  Angle.l = Int(ATan(a/b)*57.2957795) 
  If b < 0 
    Angle + 180 
  EndIf 
  If Angle < 0 : Angle + 360 : EndIf 
  If Angle > 359 : Angle - 360 : EndIf 
  ProcedureReturn Angle 
EndProcedure 

Procedure.f gSin(Angle.l) 
   ; Eingabe: Angle ( 0 - 360 ) 
   ; Ausgabe: Sine with Angle 
   ProcedureReturn Sin(Angle*0.01745329) 
EndProcedure 

Procedure.f gCos(Angle.l) 
   ; Entry Angle ( 0 - 360 ) 
   ; Output: Cosine with Angle 
   ProcedureReturn Cos(Angle*0.01745329) 
EndProcedure 

Procedure NewBullet(x.f, y.f, SpeedoX.f, SpeedoY.f) 
  AddElement(Projectile()) 
  Projectile()\x = x 
  Projectile()\y = y 
  Projectile()\SpeedoX = SpeedoX 
  Projectile()\SpeedoY = SpeedoY 
  Projectile()\Scalar = 0;5 
EndProcedure 

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 
  MessageRequester("Error", "DirectX 7 Fail!", 0) 
  End 
EndIf 

wide = 800 
High = 600 

If OpenScreen ( wide, High,32,"Standard") = 0 
  MessageRequester("Error", "No screen could be Initialized...", 0) 
  End 
EndIf 

If InitSprite3D() = 0 
  MessageRequester("DirectX fail !", "Cannot open DirectX...", #PB_MessageRequester_Ok) 
  End 
EndIf 

LoadSprite(1011, "\cursor\body1.bmp",#PB_Sprite_Texture) 
LoadSprite(1012, "\cursor\head1.bmp",#PB_Sprite_Texture) 
LoadSprite(#bullet1, "\cursor\blip00.bmp",#PB_Sprite_Texture) 
LoadSprite(#enemy1, "\cursor\blip11.bmp",#PB_Sprite_Texture) 

CreateSprite(#Cursor2,12,12) ; non displayed for sudo cursor collision testing
StartDrawing(SpriteOutput(#Cursor2)) 
Box(0,0,12,12,#Yellow) 
StopDrawing() 

CreateSprite(#Bullet2,1,1) ; non displayed for smallest possible collision testing region
StartDrawing(SpriteOutput(#Bullet2)) 
Box(0,0,1,1,#Red) 
StopDrawing() 

Sprite3DQuality(#PB_Sprite3D_BilinearFiltering) 

CreateSprite3D(#Head, 1011) 
CreateSprite3D(#Body, 1012) 
CreateSprite3D(#Bullet, #bullet1) 
CreateSprite3D(#Target,#enemy1) 

;LoadSprite(#Cursor, "\cursor\cursor0.bmp",#PB_Sprite_Memory) 
CreateSprite(#Cursor,32,32,#PB_Sprite_Memory) ; because i dont have the actual cursor used...
StartDrawing(SpriteOutput(#Cursor)) 
Circle(16,16,16,#Blue) 
Circle(16,16,14,#Black) 
 Line(15,8,0,16,#Blue) 
 Line(8,15,16,0,#Blue) 
StopDrawing() 

Player1.Player 
Player1\hSIZE = 0;16 ; was 16 
Player1\x = wide/2 - Player1\hSIZE 
Player1\y = High/2 - Player1\hSIZE 
Player1\Speedo = 2 ; was 2 
Player1\TrickSpeedo = 2 ; was 2 
Player1\Angle = 0 ; was 270 

Maus.Point 

targetflag = 1 

For y.l = 0 To 97 Step 32 
      For x.l = 0 To 800 Step 32 
         AddElement(target()) 
         target()\x = x 
         target()\y = y 
      Next 
   Next 

Repeat 
  ClearScreen(RGB(0,0,0)) 

  ExamineMouse() 
  ExamineKeyboard() 

  Maus\x = MouseX() ; - 16 
  Maus\y = MouseY() ; - 16 
  a.l = Maus\y - Player1\y 
  b.l = Maus\x - Player1\x 
  Player1\GoalAngle = gATan(a, b) 
  
  If KeyboardPushed(#PB_Key_Left) Or KeyboardPushed(#PB_Key_A) 
    Player1\Angle - Player1\TrickSpeedo 
  EndIf 
  If KeyboardPushed(#PB_Key_Right) Or KeyboardPushed(#PB_Key_D) 
    Player1\Angle + Player1\TrickSpeedo 
  EndIf 
  ; 
  If KeyboardPushed(#PB_Key_Up) Or KeyboardPushed(#PB_Key_W) 
    Player1\x + (gCos(Player1\Angle) * Player1\Speedo) 
    Player1\y + (gSin(Player1\Angle) * Player1\Speedo) 
  EndIf 
  If KeyboardPushed(#PB_Key_Down) Or KeyboardPushed(#PB_Key_S) 
    Player1\x - (gCos(Player1\Angle) * Player1\Speedo) 
    Player1\y - (gSin(Player1\Angle) * Player1\Speedo) 
  EndIf 
  
  If Player1\x > wide - 32 
    Player1\x = wide - 32 
  EndIf 
  If Player1\x < 0 
    Player1\x = 0 
  EndIf 
  If Player1\y > High - 32 
    Player1\y = High - 32 
  EndIf 
  If Player1\y < 0 
    Player1\y = 0 
  EndIf 
  
Start3D() 

  If MouseButton(1) 

    If Delaytime < 1 
      Delaytime = 9 ; was 10 THIS IS HOW FAST YOU FIRE 
      Speedo.l = 8 
      Lifetime.l = 12 ; was 33 
      SpeedoX.f = gCos(Player1\GoalAngle) 
      SpeedoY.f = gSin(Player1\GoalAngle)      
    NewBullet(Player1\x + Player1\hSIZE + SpeedoX * Lifetime, Player1\y + Player1\hSIZE + SpeedoY * Lifetime, SpeedoX * Speedo, SpeedoY * Speedo) 
    ;DisplaySprite3D(#Bullet, Int(Player1\x), Int(Player1\y) ) 
    EndIf 

  If Delaytime > 0 
    Delaytime - 1 
  EndIf 
EndIf 


    RotateSprite3D(#Head, Player1\Angle, 0) 
    DisplaySprite3D(#Head, Int(Player1\x-15), Int(Player1\y-15),200) 
    RotateSprite3D(#Body, Player1\GoalAngle, 0) 
    DisplaySprite3D(#Body, Int(Player1\x-15), Int(Player1\y-15)) ;, 80) ; was 20 

    ResetList(Projectile()) 
    While NextElement(Projectile()) 
      If Projectile()\x < 0 Or Projectile()\y < 0 Or Projectile()\x > wide Or Projectile()\y > High Or Projectile()\Dimmer < - 254 
        DeleteElement(Projectile()) 
      Else 
        If SpriteCollision(#bullet2, Projectile()\x,Projectile()\y, #Cursor2, Maus\x-5, Maus\y-5) 
          DeleteElement(Projectile()) 
          Break 
        EndIf 
        CompensateX.l=SpriteWidth(#Bullet1)/2
        CompensateY.l=SpriteHeight(#Bullet1)/2
        Projectile()\x + Projectile()\SpeedoX 
        Projectile()\y + Projectile()\SpeedoY 
        Projectile()\Scalar + 1 ; size to increase by 1 to 10 but 10 is HUGE 
        Projectile()\Dimmer - 3 ; rate of decay... 10 fast 1 slow (3 to 7 is good for fire BALANCED by scalar!) 
        Projectile()\Angle + 10 ; rotation try 3, 8, 12 and 48 
       ; ZoomSprite3D(#Bullet, Projectile()\Scalar, Projectile()\Scalar) 
        RotateSprite3D(#Bullet, Int(Projectile()\Angle), 0) 
        DisplaySprite3D(#Bullet, Int(Projectile()\x-CompensateX), Int(Projectile()\y-CompensateY) , Int(Projectile()\Dimmer)) 
      ;DisplaySprite(#Bullet2,Int(Projectile()\x), Int(Projectile()\y)) 
      EndIf 
    Wend 
    
    ResetList(target()) 
    While NextElement(target()) 
        DisplaySprite3D(#Target, Int(target()\x), Int(target()\y) ) 
    Wend 
    ; *************************************************************************************** 
    ; check for collision {{THUNK OUT BY Ice-Soft}} mangeld by Rook Zimbabwe 
     ; *************************************************************************************** 
     ResetList(Projectile()) 
     While NextElement(Projectile()) 
         If Projectile()\x > 0 Or Projectile()\y > 0 Or Projectile()\x < wide Or Projectile()\y < High 
          
               ForEach(target()) 
                  If SpriteCollision(#bullet2, Projectile()\x,Projectile()\y, #enemy1, target()\x, target()\y) 
                
                    DeleteElement(target()) 
                    DeleteElement(Projectile()) 
                    Break 
                  EndIf 
                Next  
            EndIf 
     Wend 
 Stop3D() 


 DisplayTransparentSprite(#Cursor, Maus\x-15, Maus\y-15) 
 ;DisplaySprite(#Cursor2,Maus\x-5,Maus\y-5) 
  
  FlipBuffers() 
    
  If KeyboardPushed(#PB_Key_Escape) 
    Quit = 1 
  EndIf 

  Delay(3) 
Until Quit 
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Baldrick,
GREAT SOLUTION! use a point as a checker! I would have thought of that myself... in about 2,000,000 1/2 years [ plus 16 days!] ) :D
I have disabled the displayed bullet zooming as this bit needs more work to get accuracy.
I think the problem with the scalaing is the rotation... I think the rotation throws everything else off! I am going to try your code with simple scalaing and no rotation as well to see whats up! 8)

Thanks for the brainwork!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Post Reply