New game/experimental-thing (Update 1)

Posted by link2x101 on Aug. 2, 2011, 6:07 p.m.

DrawFormer

Uses surfaces to draw two types of land, and converts them into sprites for the floor and deadly objects.

You can then play on them using a crudely-written platforming ball.

Left-click - Draw floor/wall.

Right-click - Draw spikes/deadly-type-things.

R - Erase drawings.

T - Place player. (Left/Right - Move. Z - Jump)

Supports 'level'-sharing.

S - Save.

L - Load.


It's highly experimental, just me testing out surfaces when I got the idea and went and made it.

(PS: Resolution is lower because my computer runs it a little slow as is… I'll up it on request.)


If anyone's wondering, I'm using this code for smooth mouse-based drawing:

Create event:

lx = mouse_x;
ly = mouse_y;

Draw event:

...
draw_line(mouse_x, mouse_y, lx, ly);
lx = mouse_x;
ly = mouse_y;
...


Doing so allows it to go from my last mouse position (usually not too far away) to my current position, keeping it all nice and gap-free. The faster your computer and slower you draw, the more detailed the line can be.


Have fun O.o

Download

Comments

BP Scraps 13 years, 3 months ago

This is neat.

Also, F1 doesn't give me help, and when I close the app, it gives me an error code telling me it's trying to use non-existent surfaces.

link2x101 13 years, 3 months ago

I'm not sure why you're getting that error. O.o

I'm sorry that F1 isn't helping you. XD Fixed now, updating in a second.

link2x101 13 years, 3 months ago

Done XD

DesertFox 13 years, 3 months ago

You know that you could use bezier-splines to make actual curves regardless of how fast you moved the mouse :D

link2x101 13 years, 3 months ago

Well if you wanna tell me how to add that, go for it. XD

DesertFox 13 years, 3 months ago

Yay mathiness FORWARD! Lemme find my codestuff.

DesertFox 13 years, 3 months ago

Hookay. Here we go. This is a REALLY quick and dirty fast tutorial on bezier splines/curves. If you don't know what they are, look here:

http://en.wikipedia.org/wiki/B%C3%A9zier_curve

For a SINGLE n-dimensional bezier curve of 4 points (Q0,Q1,Q2,Q3, where Q0 and Q3 are the endpoints, and Q1 and Q2 are the so-called handles, or influences), to get the position of point P along the curve at time T (where T is 0 <= T <= 1, with 0 being the start of the curve, and 1 being the end of the curve), you simply use this formula:

P is equal to 1-T cubed times Q0, plus 3T times 1-T squared times Q1, plus 3T squared times 1-T times Q2, plus 3T times Q3. There is a little pattern to it, you see. Expanded into code, for dimension n, it is:

P.n = (1-T) * (1-T) * (1-T) * Q0.n

+ 3 * T * (1-T) * (1-T) * Q1.n

+ 3 * T * T * (1-T) * Q2.n

+ T * T * T * Q3.n;

Where n is x, y, z, whatever coordinate you need.

Joining multiple curves is easy. Assuming two curves made up of points Q0,Q1,Q2,Q3 and R0,R1,R2,R3 respectively, all you need to do is make R0 be equal to Q3, and make sure that the line between Q2 and R1 intersects Q3/R0.

Thats splines!

Now, turning this into drawing a contiguous line is a bit more work, but it is essentially using the mouse's position for the new endpoint, and using the mouse's vector (speed + direction) as a way of getting the handle or influence.

Quietus 13 years, 3 months ago

wow.. that's awesome. i dunno how you could turn that into a complete game but you should. lol.

link2x101 13 years, 3 months ago

I'm thinking maybe use it to release a complete platformer, and let it have a level editor. But first, I need a better way of saving maps. XD

DesertFox 13 years, 3 months ago

Oh, and there's ways to do collision detection with bezier curves, so there's that too :D