Scrolling Game Development Kit Forum
SGDK Version 1 => Projects => Topic started by: bat on 20060729, 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 (http://www.freewebs.com/monkeycheeseface)
that's all.

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

<script language=javascript>
function totally_off_topic() {
document.write('wow, my 200th post yay!') }
</script>
;D

<script>
totally_off_topic();
</script>
I figure you actually want to call it some time, so I did it for you.

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

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.

roboninja is going a tad bit slower than i was hoping (i went 2 scout camp) but i back on track! ;)

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.

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

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 ;)

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!

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 nonright 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 nonhypotenuse side to the hypotenuse.
Tan: The Tan of the angle in this corner is the ratio of the opposite side to the adjacent nonhypotenuse 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").

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 counterclockwise 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...

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)

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!!!

You need to put "Option Explicit" at the top of your script to force you to declare variables before you try to use them. Then you also need to initialize "Target" and "ninja" since you never set those variables to anything befor trying to use them as if they were variables representing sprites.

Also, AngleRadians is always reset to 0 when the script is called, and then updated after it is used, and the updated value is not used before it's lost. I think you need to declare AngleRadians in a global scope.

whoa... so thats all it was? thanks! ;D

You need to put "Option Explicit" at the top of your script to force you to declare variables before you try to use them. Then you also need to initialize "Target" and "ninja" since you never set those variables to anything befor trying to use them as if they were variables representing sprites.
how do you declare/initialize variables in VB? and is there a command that "grabs" a sprite that is not your main character and lets you use it as a variable?