PDA

View Full Version : Teach me splines for $


Leper
10-24-2005, 03:39 AM
Hey, I pmed IndiePath about it and he suggested I ask others about this, so here I am. Seeing as how he hasn't used splines yet, I'd much rather pay for someone who has. But unless anyone else steps to the plate, ultimately I'll still accept his guidance seeing as how he is an advanced coder and could probably grasp the spline concept quickly.

I'll pay roughly $50.00 or even $100.00 (or something you can negotiate with me) to anyone to take some time out of their day to hold my hand and teach me splines like a tutor would teach a kid fractions.

I think I would learn splines rather quickly if I just had someone who could sit with me and show me what to do, walk me through the steps, and hold my hand. I firmly believe this could be done via ICQ.

I would need them to be available and take time out of their day at 5pm to 7pm on a monday, thursday or friday. Saturdays are a no go, and sundays are a no go too.

At any rate, please PM me if you would like to step to the plate and show me splines. It should only take two hours and I will pay somewhere around $50.00 to $100.00 so you can just stop what you're doing and teach me for 2 hours. That's it! If I need more schoolin' then I'll need more cash. Hopefully not! But it's just that simple.

This project will be outlined on a written contract, as a contractor I'm good at writing these. However, we can change the contract multiple times until we feel mutual about it. Then we will both sign the contract via SNAIL MAIL, and after signage payment will be sent via the terms outlined on said contract.

I am highly professional and will expedite the contract immediatley to anyone who is sincerely interested and requests me to do so.

I will pay via credit card, personal check, paypal, or money order in US money.

patrox
10-24-2005, 03:51 AM
Try the PTK game engine (http://www.phelios.com/ptk), it has build in splines, and it's very easy to use ( several blitz basic programmers got it to work within hours )

pat.

Leper
10-24-2005, 03:57 AM
Try the PTK game engine (http://www.phelios.com/ptk), it has build in splines, and it's very easy to use ( several blitz basic programmers got it to work within hours )

pat.

Sounds promising, but I dont know the first thing about including .h files (thats a c++ library isnt it?) into a blitzmax program.

I can imagine the poeple that got it to work within hours already knew how to convert libraries right? I can imagine they "translated" from C to BlitzMax..

But seeing how C is usually this:


void functionsarekewl(int,float,string)
{
}

void main()
{
float Fsoblah
int Iblahblah
int Iblah
int Iblah
string Syoyocheckitout = ("yo yo check it out"); // lol
while Iblah <= 10
{
Fsoblah == 0.5;
Iblahblah ++;
Iblah ++;
Iyoyocheckitout == Ihomeboyyyyy; // yeahhh comment homeboy!
SendMessage(Syoyocheckitout); //Send the message via function

if (Iblahblah = Iblah) && (Iblahblah = Iblahblah) || (Iblah=Iblah)
{
Iblah==FloatToInt(Fsoblah);
}
}
functionsarekewl(5,5.5,"lol")
}


++ means incriment by one
-- decriment by one
&& means AND
|| means OR
== means assign variable

am I right? I think I am but this is off of memory.

ManuelFLara
10-24-2005, 04:10 AM
I think that when he's says "got it to work within hours", he actually means that people who used to code in Blitz switched to PTK & C++, not that they ported the code to BlitzMax.

If you want to understand how to "use" splines (if you already have some code to handle them), that is really really easy. It's like using quaternions. Understanding them from a mathematical point of view is a whole different story and a lot more complex, as with quats, but fortunately you don't have to in order to use them. Just grab some spline handling source code from the web and use it. It looks very similar to PTK's KSpline functions.

Also, can I ask what are the splines for? If your intention is writing a Zuma clone let me tell you "spline code" will be the smaller of your problems.

Jack Norton
10-24-2005, 04:11 AM
I'm one of those blitzbasic users who managed to make a working program in 2h with PTK, knowing nothing of C.
I still don't know C++ even today, this didn't prevent me from making 8 games in 2 years (about the quality well judge yourself)... once you get used to VC debugger you won't come back to blitz one, trust me :D

Leper
10-24-2005, 04:18 AM
I am trying to create a Galaga clone right now. Galaga was my most favorite game growing up (I spent hours at the local arcade pumping my dad's quarters into that game)

I even went to dave and busters and played galaga a few weeks ago and got to level 50! I was so amazed with myself. I love galaga. I want to make a galaga clone.

I also want to add in my own additions to it etc. I know that galaga clones are everywhere but I still want to make one as a galaga fan, and it would be my first shmup of hopefully many to come! :)

Right now I have good sfx, good music, and a good engine built, but the alien ships just fly down and go randomly left and right and its retarted.

joe
10-24-2005, 04:44 AM
here is some bmax code for you to play with. do you mean something like this?


Strict

Graphics 640,480,0

Global x1:Int=100
Global y1:Int=100
Global vx1:Int=100
Global vy1:Int=100
Global x2:Int=540
Global y2:Int=380
Global vx2:Int=540
Global vy2:Int=380

Global point:Int=0

Repeat
Cls

drawbezier (x1,y1,vx1,vy1,x2,y2,vx2,vy2)

SetColor 255,0,0
Select point
Case 0
DrawOval x1-2,y1-2,5,5
If MouseDown(2) Then
x1=MouseX()
y1=MouseY()
EndIf
Case 1
DrawOval vx1-2,vy1-2,5,5
If MouseDown(2) Then
vx1=MouseX()
vy1=MouseY()
EndIf
Case 2
DrawOval x2-2,y2-2,5,5
If MouseDown(2) Then
x2=MouseX()
y2=MouseY()
EndIf
Case 3
DrawOval vx2-2,vy2-2,5,5
If MouseDown(2) Then
vx2=MouseX()
vy2=MouseY()
EndIf
End Select

If MouseDown(1) Then changepoint

DrawText "Use left mousebutton to select next point",10,10
DrawText "Use right mousebutton to move current point",10,30

Flip
FlushMem

Until KeyDown(KEY_ESCAPE)

End

Function changepoint()
point=(point+1) Mod 4
While MouseDown(1)
Wend
End Function


Function drawbezier (x1,y1,vx1,vy1,x2,y2,vx2,vy2)
For Local t:Float=0 To 1 Step.01
Local pointx:Float = x1*(1-t)^3 + 3*vx1*(1-t)^2*t + 3*vx2*(1-t)*t^2 + x2*t^3
Local pointy:Float = y1*(1-t)^3 + 3*vy1*(1-t)^2*t + 3*vy2*(1-t)*t^2 + y2*t^3
Plot pointx,pointy
Next
End Function

Leper
10-24-2005, 04:50 AM
Joe: You're just the guy to teach me this. I'll pay you, since you're in Germany we can work this out. you can always send me lesson plans and I'll pay you $25.00 for each tutorial, and I'd like 4. If you want to, pm me and we can get something started! If anyone else is reading this and is willing to make some $ for tutorials pm me also.

Jack: VC? Visual C? Does that mean I'd have to purchase the msdn Visual C++ that is overpriced? then purchase the PTK SDK and then learn how to use PTK? I just bought blitzmax and would honestly hate to have to switch over because I dont know splines. I think that knowing splines would be better than switching because of a handicap per se

Savant
10-24-2005, 05:50 AM
Sounds promising, but I dont know the first thing about including .h files (thats a c++ library isnt it?) into a blitzmax program.
I don't want to offend, but the vibe I'm getting from your posts is that splines are the least of your worries right now. You need a more solid grasp on programming languages before you start delving into more complicated subjects.

Maybe spend some time doing some simpler projects and work up to the project you want to use these splines for. Skip Galaga for now - do Space Invaders.

Currently this has all the earmarks of someone shooting WAY beyond their limits and the project crashing and burning is only a matter of time.

Just trying to be helpful, seriously, please don't take personal offense.

Leper
10-24-2005, 05:52 AM
I don't want to offend, but the vibe I'm getting from your posts is that splines are the least of your worries right now. You need a more solid grasp on programming languages before you start delving into more complicated subjects.

Maybe spend some time doing some simpler projects and work up to the project you want to use these splines for. Skip Galaga for now - do Space Invaders.

Currently this has all the earmarks of someone shooting WAY beyond their limits and the project crashing and burning is only a matter of time.

Just trying to be helpful, seriously, please don't take personal offense.

Perhaps you're right. I tend to get over-zealous at times. Maybe I'll just do space invaders for now, I appreciate your honesty! Actually you are only posting what a little voice in my head has been sayin' :rolleyes:

Savant
10-24-2005, 05:55 AM
Perhaps you're right. I tend to get over-zealous at times. Maybe I'll just do space invaders for now, I appreciate your honesty! Actually you are only posting what a little voice in my head has been sayin'
Yeah, plus, think about it - Space Invaders has a LOT in common with Galaga. Controlling a player ship, shooting, collisions, points, etc. Building that game first and then expanding on it to build Galaga will give you a good leg up.

Good luck with it!

Batley
10-24-2005, 06:11 AM
Pong, Space Invaders and Break out clones are best to do when you're learning.

joe
10-24-2005, 07:00 AM
@Leper: I'm sure you can master it yourself. I am also no expert on bezier curves.

First, I have changed the source a little bit so it is easier for you to play with (I have inserted that the tangents will be displayed):


Strict

Graphics 640,480,0

Global x1:Int=100
Global y1:Int=100
Global vx1:Int=200
Global vy1:Int=100
Global x2:Int=540
Global y2:Int=380
Global vx2:Int=640
Global vy2:Int=380

Global point:Int=0

Repeat
Cls

drawbezier (x1,y1,vx1,vy1,x2,y2,vx2,vy2)

SetColor 255,0,0

If point=0 Then SetColor 255,255,0 Else SetColor 255,255,255

DrawOval x1-2,y1-2,5,5
If MouseDown(2) And point=0 Then
x1=MouseX()
y1=MouseY()
EndIf

If point=1 Then SetColor 255,255,0 Else SetColor 255,255,255

DrawOval vx1-2,vy1-2,5,5
If MouseDown(2) And point=1 Then
vx1=MouseX()
vy1=MouseY()
EndIf

If point=2 Then SetColor 255,255,0 Else SetColor 255,255,255

DrawOval x2-2,y2-2,5,5
If MouseDown(2) And point=2 Then
x2=MouseX()
y2=MouseY()
EndIf

If point=3 Then SetColor 255,255,0 Else SetColor 255,255,255

DrawOval vx2-2,vy2-2,5,5
If MouseDown(2) And point=3 Then
vx2=MouseX()
vy2=MouseY()
EndIf

SetColor 255,255,255

If MouseDown(1) Then changepoint

DrawText "Use left mousebutton to select next point",10,10
DrawText "Use right mousebutton to move current point",10,30

Flip
FlushMem

Until KeyDown(KEY_ESCAPE)

End

Function changepoint()
point=(point+1) Mod 4
While MouseDown(1)
Wend
End Function


Function drawbezier (x1,y1,vx1,vy1,x2,y2,vx2,vy2)
DrawLine x1,y1,vx1,vy1
DrawLine x2,y2,vx2,vy2
For Local t:Float=0 To 1 Step.01
Local pointx:Float = x1*(1-t)^3 + 3*vx1*(1-t)^2*t + 3*vx2*(1-t)*t^2 + x2*t^3
Local pointy:Float = y1*(1-t)^3 + 3*vy1*(1-t)^2*t + 3*vy2*(1-t)*t^2 + y2*t^3
Plot pointx,pointy
Next
End Function


Then you can read the following tutorial. It's OpenGL but the main point is to get the maths stuff into your brain (you even don't need to understand it because you just have to enter those formulas into your source) :-)

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=28

And here some more math to dive into (I think you don't have to understand everything, just if you want to get deeper in it):

http://www.moshplant.com/direct-or/bezier/
http://astronomy.swin.edu.au/~pbourke/curves/bezier/
http://www.math.ubc.ca/~cass/gfx/bezier.html
http://www.ibiblio.org/e-notes/Splines/Bezier.htm
http://antigrain.com/research/adaptive_bezier/

If you have any questions you can pm or mail me at any time, of course - I won't take your money ;)

adrian
10-24-2005, 11:36 AM
If it helps I can give you the source code for a little galaga thing I did a while back.

http://www.ramspeed.com/galagaAlpha/galaga.html

It's in Lingo but wouldnt be too hard to port.

Leper
10-24-2005, 11:42 AM
What's Lingo?

Jim Buck
10-24-2005, 12:02 PM
Lingo is the language used inside of Director for creating Shockwave files.

Leper
10-24-2005, 12:48 PM
Hmm I wouldnt be good at porting it!

techbear
10-31-2005, 06:19 AM
Might I recommend a Catmull-Rom equation? This is similar to splines, but better (for me, anyway) because the line passes directly thru all four points that make up the line.

To use the function below, just plug in the four consecutive points that define the line, along with the position (t) between the second and third points that you're looking for (0.0 - 1.0). You get back the x,y point you were looking for.

//***************************************
struct TrackPoint
{
float x,y;
};

//***************************************
void PointOnCurve(TrackPoint &out, float t, TrackPoint p0, TrackPoint p1, TrackPoint p2, TrackPoint p3)
{
float t2 = t * t;
float t3 = t2 * t;
out.x = 0.5f * ( ( 2.0f * p1.x ) +
( -p0.x + p2.x ) * t +
( 2.0f * p0.x - 5.0f * p1.x + 4 * p2.x - p3.x ) * t2 +
( -p0.x + 3.0f * p1.x - 3.0f * p2.x + p3.x ) * t3 );
out.y = 0.5f * ( ( 2.0f * p1.y ) +
( -p0.y + p2.y ) * t +
( 2.0f * p0.y - 5.0f * p1.y + 4 * p2.y - p3.y ) * t2 +
( -p0.y + 3.0f * p1.y - 3.0f * p2.y + p3.y ) * t3 );
}

Jim Buck
10-31-2005, 08:14 AM
I also give a thumbs-up to Catmull-Rom curves for the same reasons (curve passes through the points). I used these in Twisted Metal 4 for various objects in the world that travelled around on paths (train, helicopter, etc). Though, I don't know how easy they are to work with for the person that has to create them.

Leper
10-31-2005, 08:18 AM
I simply do not understand these whatchamacallit roms. I'll try to decipher them tonight when I get home.... Keyword... TRY.....

I've just finished the level structure of my game.. (the ship will warp from level to level now and its pretty sweet!)

My warp fx are kinda oldschool though and I know you guys will make fun (just lines that go fast then turn back into dots to represent the stars) of them! :p

I'm now ready to start programming my levels..

I'm going to post a question about that on the forums here.

techbear
10-31-2005, 08:28 AM
Mebbe I wasn't clear. The function I gave you IS the Catmull-Rom equation. You don't have to understand its inner workings (I don't). Just use the function, and trust it.

The point of any spline-type path is that your object travels a smooth, twisting path, and all you have to do is define a few points along that path. This function fills the bill. :)

Leper
10-31-2005, 09:08 AM
px is a seperate point?

Leper
10-31-2005, 03:04 PM
Check it out.. The numbers help me.. so do the coordinates..
Use the mouse wheel.
This editor helps me because it goes with the game's 800x600 coordinates.

This way I can place points in the negative areas as well.

Strict

Graphics 1024,768,32
SetBlend LIGHTBLEND
Global x1:Int=540 'pount 0
Global y1:Int=125 'point 0
Global vx1:Int=200 '1
Global vy1:Int=350 '1
Global x2:Int=420 '2
Global y2:Int=670 '2
Global vx2:Int=700 '3
Global vy2:Int=350 '3
Global StepSetting = .1
Global counter=0
Global point:Int=0
Global MouseWas
Global GridPlot
Global Gridy
Global swap_x1=x1
Global swap_x2=x2
Global swap_vx1=vx1
Global swap_vx2=vx2
Global swap_y1 = y1
Global swap_y2 = y2
Global swap_vy1 = vy1
Global swap_vy2 = vy2


Repeat
Cls
SetColor 130,130,140
DrawLine 100,100,100,700
DrawLine 100,100,800,100
DrawLine 800,100,800,700
DrawLine 800,700,100,700

DrawLine 800,100,900,100
DrawLine 800,700,900,700
DrawLine 900,100,900,700

SetColor 90,90,100
For GridY= 1 To 18
For GridPlot = 1 To 21
Plot (GridPlot*32)+100,(GridY*32)+100
Next
Next
SetColor 215,215,215
Keys()

drawbezier (x1,y1,vx1,vy1,x2,y2,vx2,vy2)

SetColor 200,200,200
DrawText "mouse: "+(MouseX()-100)+","+(MouseY()-100),0,40
SetColor 200,200,200
DrawText "(R)everse (M)irror (F)lip (L)oop",0,70
DrawText "Mouse Wheel Changes Selection - [W][A][S][D] and RIGHT MOUSE move point",250,15

If point=0 Then SetColor 255,255,0 Else SetColor 200,200,200
DrawText "p0 coord: "+(x1-100)+","+(y1-100)+" - Start",0,0
DrawText "0 - Start",x1-2,y1-2
If MouseDown(2) And point=0 Then
x1=MouseX()
y1=MouseY()
EndIf




If point=1 Then SetColor 255,255,0 Else SetColor 200,200,200
DrawText "p1 coord: "+(vx1-100)+","+(vy1-100),0,10
DrawText "1",vx1-2,vy1-2
If MouseDown(2) And point=1 Then
vx1=MouseX()
vy1=MouseY()
EndIf
If point=2 Then SetColor 255,255,0 Else SetColor 200,200,200
DrawText "p2 coord: "+(x2-100)+","+(y2-100)+" - Finish",0,20
DrawText "2 - Finish",x2-2,y2-2
If MouseDown(2) And point=2 Then
x2=MouseX()
y2=MouseY()
EndIf
If point=3 Then SetColor 255,255,0 Else SetColor 200,200,200
DrawText "p3 coord: "+(vx2-100)+","+(vy2-100),0,30

DrawText "3",vx2-2,vy2-2
If MouseDown(2) And point=3 Then
vx2=MouseX()
vy2=MouseY()
EndIf
SetColor 255,255,255

If MouseZ() < MouseWas Then point=(point+1) Mod 4
If MouseZ() > MouseWas Then point=(point-1) Mod 4
If point = -1 point = 3 ; If point = 4 Then point = 0
MouseWas = MouseZ()
Flip
FlushMem

Until KeyDown(KEY_ESCAPE)

End


Function drawbezier (x1,y1,vx1,vy1,x2,y2,vx2,vy2)
counter = 0
SetColor 50,50,100
DrawLine x1,y1,vx1,vy1
DrawLine x2,y2,vx2,vy2

SetColor 255,50,50
For Local t:Float=0 To 1 Step .001
counter:+1
Local pointx:Float = x1*(1-t)^3 + 3*vx1*(1-t)^2*t + 3*vx2*(1-t)*t^2 + x2*t^3
Local pointy:Float = y1*(1-t)^3 + 3*vy1*(1-t)^2*t + 3*vy2*(1-t)*t^2 + y2*t^3
SetColor t*10,00,00
DrawRect pointx,pointy,2,2

SetColor t*1000,t*90,t*90
Plot pointx,pointy
If Counter = Rnd(20,90)
SetColor 50,50,255
Plot pointx,pointy
Counter = 0
EndIf
Next
End Function

Function Keys()
If KeyHit(Key_S)
If point = 0 Then y1:+1
If Point = 1 Then vy1:+1
If Point = 2 Then y2:+1
If Point = 3 Then vy2:+1
EndIf
If KeyHit(Key_W)
If Point = 0 Then y1:-1
If Point = 1 Then vy1:-1
If Point = 2 Then y2:-1
If Point = 3 Then vy2:-1
EndIf
If KeyHit(Key_A)
If Point = 0 Then x1:-1
If Point = 1 Then vx1:-1
If Point = 2 Then x2:-1
If Point = 3 Then vx2:-1
EndIf
If KeyHit(Key_D)
If Point = 0 Then x1:+1
If Point = 1 Then vx1:+1
If Point = 2 Then x2:+1
If Point = 3 Then vx2:+1
EndIf

If KeyHit (Key_M)
swap_x1 = x1
swap_x2 = x2
swap_vx1 = vx1
swap_vx2 = vx2

x1 = swap_x2
vx1 = swap_vx2
x2 = swap_x1
vx2 = swap_vx1
EndIf

If KeyHit (Key_F)
swap_y1 = y1
swap_y2 = y2
swap_vy1 = vy1
swap_vy2 = vy2

swap_x1 = x1
swap_x2 = x2
swap_vx1 = vx1
swap_vx2 = vx2

y1 = swap_y2
vy1 = swap_vy2
y2 = swap_y1
vy2 = swap_vy1
EndIf

If KeyHit (Key_R)
swap_y1 = y1
swap_y2 = y2
swap_vy1 = vy1
swap_vy2 = vy2

swap_x1 = x1
swap_x2 = x2
swap_vx1 = vx1
swap_vx2 = vx2

x1 = swap_x2
vx1 = swap_vx2
x2 = swap_x1
vx2 = swap_vx1
y1 = swap_y2
vy1 = swap_vy2
y2 = swap_y1
vy2 = swap_vy1
EndIf

If KeyHit (Key_L)
swap_y1 = y1
swap_y2 = y2
swap_vy1 = vy1
swap_vy2 = vy2

swap_x1 = x1
swap_x2 = x2
swap_vx1 = vx1
swap_vx2 = vx2

y1 = swap_y2
vy1 = swap_vy1
x1 = swap_x2
vx1 = swap_vx2
vx2 = swap_vx1
vy2 = swap_vy1
EndIf

EndFunction



build upon it! make an even better one :cool:

WaveRider
01-03-2006, 12:41 AM
If it helps I can give you the source code for a little galaga thing I did a while back.

http://www.ramspeed.com/galagaAlpha/galaga.html

It's in Lingo but wouldnt be too hard to port.


I would love to see the source for that if you're still offering.