Author Topic: the targeter... hehe,sorry...  (Read 3029 times)

bat

  • Fanatic
  • ***
  • Posts: 234
  • Cheak out the B*t project
    • MSN Messenger - ethanbatmay@hotmail.com
    • Yahoo Instant Messenger - ethanbatmay
    • View Profile
    • The B*t project
    • Email
the targeter... hehe,sorry...
« on: 2006-10-10, 10:31:59 PM »
Option Explicit
dim
AngleRadians=0

Sub Player_OnControllerMove(OldActions, NewActions)
  TargetSprite.X = PlayerSprite.X + Cos(AngleRadians) * 100
  TargetSprite.Y = PlayerSprite.Y - Sin(AngleRadians) * 100
  if ACTION_BUTTON3 then
  AngleRadians = AngleRadians + 3.14159265 / 18
  Elseif ACTION_BUTTON4 then
  AngleRadians = AngleRadians + 3.14159265 / 18
 
End Sub




yah, thats my code, i cant get it to work, Durnard,or Blue M. please explain how to make a simple targeter that you aim around a point, i just keep getting errors... i don't get "where" sgdk joins with vb script,
sorry to be such a pain, i just don't get it...
~bat

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: the targeter... hehe,sorry...
« Reply #1 on: 2006-10-11, 01:07:31 PM »
I don't have time for a detailed reply, but I can tell you that that code is nowhere close to working yet.

Changing the TargetSprites positition should be within the if blocks if a buttons pressed.
The if blocks are wrong for determining whether a button is being pressed or not.  See almost any example script for correct way.
Also, need to end ifs with and "end if" line

The AngleRadians  thing is kinda screwed up.  You need a separate function.  Either lookup in a VB forum for a function to convert 2 coordinates to the angle between them in radians, or I think I have one and can post it later.

Also, you have to define TargetSprite somehow and I don't see how that is done.


bat

  • Fanatic
  • ***
  • Posts: 234
  • Cheak out the B*t project
    • MSN Messenger - ethanbatmay@hotmail.com
    • Yahoo Instant Messenger - ethanbatmay
    • View Profile
    • The B*t project
    • Email
Re: the targeter... hehe,sorry...
« Reply #2 on: 2006-10-11, 06:19:35 PM »
how do you access the main player directly in code.. i can't remember...
~bat

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: the targeter... hehe,sorry...
« Reply #3 on: 2006-10-11, 06:58:51 PM »
ProjectObj.GamePlayer

or for the player sprite:
ProjectObj.GamePlayer.PlayerSprite

Or for any abitrary sprite on the same layer as the playersprite, say your Target sprite:
ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(SPRITENUM)
Where SPRITENUM is the index number of your sprite, which can be found like this:

Code: [Select]
For i = 0 to ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.SpriteCount-1
  If ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(i).rDef.Name="Name of Sprite"
    'Where "Name of Sprite" is what you typed in SGDK interface"
    SPRITENUM=I
    Exit For
  End if
Next i

You can also use HostObj somehow to save the sprite object instead of always having to look for the index, but I forget how to do that in vbs.

Also here is the function for finding angle between 2 points in radians (X and Y are the diffrences of the 2 points:
Code: [Select]
Public Function Atan3(ByVal X As Double, ByVal Y As Double) As Double
' This function was kindly provided by Blindwig of the Extreme Visual Basic Forum.
' Returns an angle in radians, appropriately adjusted for all 4 quadrants
    Select Case X
        Case Is > 0
            If Y >= 0 Then
                Atan3 = Atn(Y / X)
            Else
                Atan3 = Atn(Y / X) + 2 * PI
            End If
        Case 0
            If Y >= 0 Then
                Atan3 = PI / 2
            Else
                Atan3 = 3 * PI / 2
            End If
        Case Is <= 0
            Atan3 = Atn(Y / X) + PI
    End Select
End Function

bat

  • Fanatic
  • ***
  • Posts: 234
  • Cheak out the B*t project
    • MSN Messenger - ethanbatmay@hotmail.com
    • Yahoo Instant Messenger - ethanbatmay
    • View Profile
    • The B*t project
    • Email
Re: the targeter... hehe,sorry...
« Reply #4 on: 2006-10-12, 10:52:25 PM »
thanks  ;D  i'm improving my code... 
~bat

bat

  • Fanatic
  • ***
  • Posts: 234
  • Cheak out the B*t project
    • MSN Messenger - ethanbatmay@hotmail.com
    • Yahoo Instant Messenger - ethanbatmay
    • View Profile
    • The B*t project
    • Email
Re: the targeter... hehe,sorry...
« Reply #5 on: 2006-10-12, 10:58:43 PM »
lol
its a target-er, scope , cross hair thingy
2nd sprite, but you told me how to access it so don't worry
~bat

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: the targeter... hehe,sorry...
« Reply #6 on: 2006-10-13, 08:10:59 AM »
I believe the phrase you're looking for is "targeting reticle".
Edward Dassmesser