Author Topic: RoboNinja  (Read 8839 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
RoboNinja
« on: 2006-07-29, 05:58:30 PM »
After... who knows how long??? i've finally settled down with in idea for a game, and the game dev. kit to use.
ummm... i was starting to make it in Gamemaker but then i had problems because theres only "Solid" and "ALL" for solidity definitions... and so i shall stick with SGDK.
to see a site i had already made with drawings etc. goto:

                            www.freewebs.com/monkeycheeseface
that's all.
~bat

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: RoboNinja
« Reply #1 on: 2006-07-29, 06:23:05 PM »
hey
cool drawings  ;D
signed ur guestbook with a lot of features you could have
if you used all of them it would take you forvever to make the game :P
but GL with it, i hope u finish it

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: RoboNinja
« Reply #2 on: 2006-07-29, 06:24:51 PM »
<script language=javascript>
function totally_off_topic()  {
document.write('wow, my 200th post yay!')  }
</script>
 ;D

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: RoboNinja
« Reply #3 on: 2006-07-29, 06:55:06 PM »
<script>
totally_off_topic();
</script>

I figure you actually want to call it some time, so I did it for you.
Edward Dassmesser

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: RoboNinja
« Reply #4 on: 2006-07-29, 07:55:20 PM »
oh yah...Id rather use a button. me likes buttons... ;)

<script language=javascript>
var totally_off_topicness = "Waaaaaaaaaay off topic"
function totally_off_topic()  {
document.write(totally_off_topicness);
</script>
<form>
<input type=button value="The off topic button" onclick=totally_off_topic>
</form>

muahahahaha...this is nerdy...

EDIT: hey durnurd, why dont you make it a moveable box, and so that all DIVs with the class moveable are automatically moveable? :P

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: RoboNinja
« Reply #5 on: 2006-08-05, 05:16:09 PM »
i can play around w/ a calculator for hours... BY THE WAY... can anyone easily explain cos tan and sin???
i have trig next year and so i have no idea untill then.
~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: RoboNinja
« Reply #6 on: 2006-08-05, 05:36:04 PM »
roboninja is going a tad bit slower than i was hoping (i went 2 scout camp) but i back on track!  ;)
~bat

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: RoboNinja
« Reply #7 on: 2006-08-06, 05:57:33 AM »
i can play around w/ a calculator for hours... BY THE WAY... can anyone easily explain cos tan and sin???
i have trig next year and so i have no idea untill then.

I find the way that cos and sin are taught is a little confusing because they just talk about ratios of sides of a right triangle.  And indeed they are derived from the lengths of sides on a right triangle, but I think their purpose (reason for existing) can be more clearly described using circles.  I would describe the Cos function as a function that gives you back the X coordinate of where a point on the rim of a circle is given an angle.  And Sin would be the Y coordinate.  I use Cos and Sin mostly to handle rotation and other circular things.  They can help you convert an angle and a distance to an X,Y coordinate.  For example, if you want to draw a circle around the point 0,0 with a radius of 2, you would follow these steps:
1. Start the angle at 0
2. Calculate X = cos(angle) * 2
3. Calculate Y = sin(angle) * 2
4. Plot a point at X, Y
5. Increase the angle slightly
6. Go to step 2

Sin and Cos can use different angle ranges depending on whether you're dealing in degrees or radians.  They are generally based on radians, so the number for angle would be a number between 0 and 2*pi, or 0 and 6.283....  You can use numbers less than 0 and greater than 2*pi, but that is the range that covers one full circle, and everything else is just a duplicate of something in that range.

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: RoboNinja
« Reply #8 on: 2006-08-07, 11:54:58 AM »
i think i'm getting it...  so it would make hundreds of pixles (0 being a pixel) kinda like this?: 

                                            0       
                                         0     0
                                        0       0
                                         0     0
                                            0


                                         
~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: RoboNinja
« Reply #9 on: 2006-08-07, 11:56:40 AM »
hey
cool drawings  ;D
signed ur guestbook with a lot of features you could have
if you used all of them it would take you forvever to make the game :P
but GL with it, i hope u finish it
me 2  ;)
~bat

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: RoboNinja
« Reply #10 on: 2006-08-07, 12:52:38 PM »
Well, it wouldn't make pixels, but it would do whatever you wanted with those particular points.  If you wanted to draw a pixel there, then it would make pixels (if BMDXCtls allowed you to draw pixels freely).  Specifically, it would make however many steps there were between 0 and 2*pi.  I usually convert the angles I'm working with to degrees for simplicity's sake and to make the stepping easier (i.e. angle = angle + 1 mod 360).  this will cause there to be 360 points around the circle.  You could, of coures, do 3600 points around the circle, and convert to 10ths of a degree.

For reference:
Angle in Degrees = (180 / pi) * Angle in Radians
Angle in Radians = (pi / 180) * Angle in Degrees

Just make sure you pass in the angle in radians when you call Sin, Cos, or Tan!
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: RoboNinja
« Reply #11 on: 2006-08-07, 05:00:36 PM »
I forgot to explain what Tan was.  Honestly I haven't found much use for it in computer / game programming.  But I can tell you what it is.  First let me give you the original definitions of Cos and Sin based on a right triangle and a non-right angle in the triangle:
Sin: The Sin of the angle in this corner is the ratio of the opposite side of the triangle to the hypotenuse -- divide the length of the side opposite of the angle by the length of the hypotenuse (0 degrees = 0, 90 degrees = 1,sin(91) degrees is the same as sin(89), etc)
Cos: The Cos of the angle in this corner is the ratio of the adjacent non-hypotenuse side to the hypotenuse.
Tan: The Tan of the angle in this corner is the ratio of the opposite side to the adjacent non-hypotenuse side (Tan(x) = Sin(x)/Cos(x))  Tan(90 degrees) is undefined because Cos(90 degrees) = 0

While I don't find Tan to be particularly useful, I do find it's inverse "Atn" or "ArcTangent" to be useful.  It can be used to convert X,Y coordinates back into an angle.  This is demonstrated in the shooting script in the function called RectToPolarState (It calls "Atn").

eric22222

  • Fanatic
  • ***
  • Posts: 177
    • View Profile
    • Eric Online
    • Email
Re: RoboNinja
« Reply #12 on: 2006-08-08, 07:50:35 AM »
And then of course you have the inverse trigonometric functions:
0 is at the right side of the circle (the anchor point). Going pi/2 counter-clockwise brings us to the top of the circle. The Y value there is 1 (X value is 0). Since sin( pi / 2 ) = 1, sin-1( 1 ) = pi / 2

But you probably won't need that anytime soon...

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: RoboNinja
« Reply #13 on: 2006-08-14, 11:17:52 PM »
Dim nExpectCount

Sub Player_OnControllerMove(OldActions, NewActions)
 
With ProjectObj.GamePlayer.PlayerSprite
      If (Not OldActions) And NewActions And ACTION_BUTTON1 Then
         If (.rDef.SolidTest(.X, .Y + .Height) Or .rDef.SolidTest(.X + .Width - 1, .Y + .Height)) Or (Not .pRideOnRef Is Nothing) Then
            .DY = - .rDef.Template.JumpHeight
         End If
      End If
   End With
End Sub

Sub RecountShots()
   Dim nSIdx, nLIdx
   With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
      nExpectCount = .SpriteCount
   End With
End Sub

Sub RemoveShot(Spr)
   Dim nIdx
   With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
      For nIdx = 0 to .SpriteCount - 1
         If .Sprite(nIdx) Is Spr Then .RemoveSprite(nIdx) : Exit Sub
      Next
   End With
End Sub

Function GetStateDeltas(DX, DY)
   With ProjectObj.GamePlayer.PlayerSprite
      Select Case .rDef.Template.StateType
      Case STATE_SINGLE
         If Abs(DX) + Abs(DY) > 1 Then
            DX = .DX / (Abs(.DX) + Abs(.DY))
            DY = .DY / (Abs(.DX) + Abs(.DY))
         Else
            If Abs(DX) + Abs(DY) < 1 Then DX = 0 : DY = -1
         End If
      Case STATE_LEFT_RIGHT
         DY = 0
         If (.CurState Mod 2) = 0 Then DX = -1 Else DX = 1
      Case STATE_8_DIRECTION
         Select Case (.CurState Mod 8)
         Case 0 : DX = 0 : DY = -1
         Case 1 : DX = 1 : DY = -1
         Case 2 : DX = 1 : DY = 0
         Case 3 : DX = 1 : DY = 1
         Case 4 : DX = 0 : DY = 1
         Case 5 : DX = -1 : DY = 1
         Case 6 : DX = -1 : DY = 0
         Case 7 : DX = -1 : DY = -1
         End Select
      Case Else
         DX = Cos((.CurState Mod 36) * 3.14159 / 18)
         DY = -Sin((.CurState Mod 36) * 3.14159 / 18)
      End Select
   End With
End Function

Sub Player_OnAfterMoveSprites
   Dim nIdx, VLeft, VTop, VRight, VBottom, VDat
   With ProjectObj.GamePlayer
      VLeft = .MapScrollX
      VTop = .MapScrollY
      VRight = VLeft + .rMap.ViewWidth
      VBottom = VTop + .rMap.ViewHeight
   End With

End Sub

Function RectToPolarState(X, Y)
   Dim Angle, Pi
   Pi = 3.14159
   If X <> 0 Then
       Angle = Atn(-Y / X)
   Else
       Angle = -(Pi / 2) * Sgn(Y)
   End If
   If X < 0 Then
       Angle = Pi + Angle
   ElseIf Y > 0 Then
       Angle = Pi * 2 + Angle
   End If
   RectToPolarState = ((Angle * 18) / Pi) Mod 36
End Function




'______my script__________________________________________________

Sub Player_OnControllerMove(OldActions, NewActions)
dim AngleRadians
 With ProjectObj.GamePlayer
  Target.X = ninja.X + Cos(AngleRadians) * 100
  Target.Y = ninja.Y - Sin(AngleRadians) * 100
 
 if ACTION_BUTTON3 then AngleRadians = AngleRadians + 3.14159265 / 18
 end with
 
end sub
     

'_________________________________________________________

HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16


ok... my script's not working...  (the first part is the script wisard jump)
~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: RoboNinja
« Reply #14 on: 2006-08-14, 11:19:53 PM »
Dim nExpectCount

Sub Player_OnControllerMove(OldActions, NewActions)
 
With ProjectObj.GamePlayer.PlayerSprite
      If (Not OldActions) And NewActions And ACTION_BUTTON1 Then
         If (.rDef.SolidTest(.X, .Y + .Height) Or .rDef.SolidTest(.X + .Width - 1, .Y + .Height)) Or (Not .pRideOnRef Is Nothing) Then
            .DY = - .rDef.Template.JumpHeight
         End If
      End If
   End With
End Sub

Sub RecountShots()
   Dim nSIdx, nLIdx
   With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
      nExpectCount = .SpriteCount
   End With
End Sub

Sub RemoveShot(Spr)
   Dim nIdx
   With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
      For nIdx = 0 to .SpriteCount - 1
         If .Sprite(nIdx) Is Spr Then .RemoveSprite(nIdx) : Exit Sub
      Next
   End With
End Sub

Function GetStateDeltas(DX, DY)
   With ProjectObj.GamePlayer.PlayerSprite
      Select Case .rDef.Template.StateType
      Case STATE_SINGLE
         If Abs(DX) + Abs(DY) > 1 Then
            DX = .DX / (Abs(.DX) + Abs(.DY))
            DY = .DY / (Abs(.DX) + Abs(.DY))
         Else
            If Abs(DX) + Abs(DY) < 1 Then DX = 0 : DY = -1
         End If
      Case STATE_LEFT_RIGHT
         DY = 0
         If (.CurState Mod 2) = 0 Then DX = -1 Else DX = 1
      Case STATE_8_DIRECTION
         Select Case (.CurState Mod 8)
         Case 0 : DX = 0 : DY = -1
         Case 1 : DX = 1 : DY = -1
         Case 2 : DX = 1 : DY = 0
         Case 3 : DX = 1 : DY = 1
         Case 4 : DX = 0 : DY = 1
         Case 5 : DX = -1 : DY = 1
         Case 6 : DX = -1 : DY = 0
         Case 7 : DX = -1 : DY = -1
         End Select
      Case Else
         DX = Cos((.CurState Mod 36) * 3.14159 / 18)
         DY = -Sin((.CurState Mod 36) * 3.14159 / 18)
      End Select
   End With
End Function

Sub Player_OnAfterMoveSprites
   Dim nIdx, VLeft, VTop, VRight, VBottom, VDat
   With ProjectObj.GamePlayer
      VLeft = .MapScrollX
      VTop = .MapScrollY
      VRight = VLeft + .rMap.ViewWidth
      VBottom = VTop + .rMap.ViewHeight
   End With

End Sub

Function RectToPolarState(X, Y)
   Dim Angle, Pi
   Pi = 3.14159
   If X <> 0 Then
       Angle = Atn(-Y / X)
   Else
       Angle = -(Pi / 2) * Sgn(Y)
   End If
   If X < 0 Then
       Angle = Pi + Angle
   ElseIf Y > 0 Then
       Angle = Pi * 2 + Angle
   End If
   RectToPolarState = ((Angle * 18) / Pi) Mod 36
End Function




'_______________my script_________________________________________

Sub Player_OnControllerMove(OldActions, NewActions)
dim AngleRadians
 With ProjectObj.GamePlayer
  Target.X = ninja.X + Cos(AngleRadians) * 100
  Target.Y = ninja.Y - Sin(AngleRadians) * 100
 
 if ACTION_BUTTON3 then AngleRadians = AngleRadians + 3.14159265 / 18
 end with
 
end sub
     

'_________________________________________________________

HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16



whoops... that not script button, anyway it says that ninja doen't exsist... BUT HE DOES!!!
~bat