Programmer needed (level generator)

Advertise your levels, contests, sites etc.

Moderator: Moporators

User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Well yes it does work. But it's hard to calculate how much should x/y-coordinates vary depending on the angle the next vertex is going... though I haven't given this thing much thoughts yet. If you have anything to suggest, do it xD
User avatar
ribot
Not banned
Posts: 2425
Joined: 19 May 2002, 16:20
Location: Miranda: the true state
Contact:

Re: Programmer needed (level generator)

Post by ribot »

some info for elma level making:

a polygon has its values written clockwise in a solid/ground polygon. if the polygon is reversed, meaning cut out from the ground, its values are written in anti-clockwise order. if you mess this up the level will still work to play, but it will look crazy. do it!
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Ok here is my problem in the pie generator. First of all you should know how I am trying to generate pie. I create a random line, then duplicate it and try to adjust the x,y values of the line to make it always standard width.

This link will probably tell something: http://zworqy.com/up/files/lal.png.

The first situation in the left is ez. The second on the right, is the same situation, but the first line is already in an angle. Of course you count it just like the first one, but somehow I fail to make a generalized function of it. In that situation, the length of x same, but x,y coordinates aren't. I've tried to do some coordinate system rotation according how the line is angled, but not managed. Maybe I'll try some other method.
User avatar
jonsykkel
Kuski
Posts: 982
Joined: 24 Nov 2009, 20:53
Contact:

Re: Programmer needed (level generator)

Post by jonsykkel »

Image
Hope u understand... :D
status:ONLINE - - -  drinking:GOFE - - - iq:85 - - - elasto mania ranking:#1
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Well yeah I understand everything you drew there but I don't know it is supposed to help me xD
User avatar
jonsykkel
Kuski
Posts: 982
Joined: 24 Nov 2009, 20:53
Contact:

Re: Programmer needed (level generator)

Post by jonsykkel »

you can use that procedure in any angle
status:ONLINE - - -  drinking:GOFE - - - iq:85 - - - elasto mania ranking:#1
welle
Kuski
Posts: 251
Joined: 15 Aug 2005, 20:52
Location: Germany

Re: Programmer needed (level generator)

Post by welle »

You should try not to use any angles at all. I usually do such stuff this way:

Image

Given the blue points (A,B,C), you want to calculate the green ones (G,K,I). (Red lines have same length, i.e. 1)
  • Calculate G and I
  • calculate the blue vectors
    a = B - A; // pointing from A to B
    b = C - B; // pointing from B to C
  • normalize them
    c = a / a.length; // pointing from D to B
    d = b / b.length; // pointing from B to E
  • rotate c counter clockwise by 90 degree
    e.x = -c.y;
    e.y = c.x; // pointing from A to F
  • multiply by pipe width
    f = e * w; // pointing from A to G
  • calculate G
    G = A + f;
  • same to calculate I
    g.x = -d.y;
    g.y = d.x; // pointing from C to H
    h = g * w; // pointing from C to I
    I = C + h;
  • Calculate K
  • Get a bisector of the angle (A,B,C)
    n = B - c + d; // pointing from J to B
  • the lines q = G + t * a (t in IR) and k = B + s * n (s in IR) intersect in K, so we need to solve the following equations:

    Code: Select all

    G.x + t * a.x = B.x + s * n.x
    G.x + t * a.x = B.x + s * n.x
    With some simple algebra we get the solution:
    t = (n.x * (B.y - G.y) - n.y * (B.x - G.x)) / (a.y * n.x - a.x * n.y);
    K = G + t * a;
  • To calculate more points like K, use the line r = K + t * b instead of q.
Well i hope this helps and i didn't make any typos. Good luck!
Last edited by welle on 10 Feb 2010, 23:19, edited 1 time in total.
User avatar
totem
39mins club
Posts: 328
Joined: 26 Dec 2007, 14:04

Re: Programmer needed (level generator)

Post by totem »

whoo nice, thank you welle :beer:
tela
Beginner kuski
Posts: 1
Joined: 10 Feb 2010, 20:44

Re: Programmer needed (level generator)

Post by tela »

if you wanna do it with angles anyway maybe this helps:

angle of pipe 1: v1
angle of pipe 2: v2
angle of red line in your drawing: (v1+v2+pi)/2
angle beta in your drawing: (v1-v2)/2
width of pipe: w

so length of red line would be w/cos(beta)

and this gives distance to the coordinates for where the "roof" lines meet:

dx = w/cos((v1-v2)/2) * cos((v1+v2+pi)/2)
dy = w/cos((v1-v2)/2) * sin((v1+v2+pi)/2)
-pi < v1-v2 < pi

using vectors like welle said might be easier and faster tho
teajay
Donator duck
Posts: 10043
Joined: 3 Apr 2003, 17:53

Re: Programmer needed (level generator)

Post by teajay »

eeww maths =)
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Thank you for those methods, I will try those tomorrow.
User avatar
Xiphias
39mins club
Posts: 4101
Joined: 23 Nov 2004, 23:05

Re: Programmer needed (level generator)

Post by Xiphias »

Ville :O time for some random update xD
Thorze wrote:I just wanted to make a cool topic like Juish have cool topics..
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

I've said like 100 times that I haven't had any time to work on it, it means 0 seconds xD I hav not even tried the methods given above. But now that you brought this up, I think I will do something over the weekend =)
User avatar
Xiphias
39mins club
Posts: 4101
Joined: 23 Nov 2004, 23:05

Re: Programmer needed (level generator)

Post by Xiphias »

You say you have had no time what so ever yet you play endless battles on belma :D:D:D:D:D:D::D:D:Dd =D=D=D xd
Thorze wrote:I just wanted to make a cool topic like Juish have cool topics..
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Ah yes of course, I meant like very often you can't find any time to make your homework because you have better things to do =)
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Well, I tried Welles method a bit and some of it worked but some I fail. Here:

Image

As you can see it doesn't look too good =) but, the thing is that the y-values are the values from the top border, not from bottom as it is in normal coordinates. Anyways we can see that if that G-spot is moved to below of the A-spot as much as it is above it now, it goes right. But the real problem here is (I guess) that K doesn't seem to make any sense. No matter where I put the C spot, the K spot always stays at the same position, and ofc it can't be like that. The direction of the vector seems to be right but it's not long enough. So I have failed something, I put my code here so someone can look and tell me how nab I am:

Code: Select all

/*
this is the polygon shown in the picture
*/

//                  A     B     C
$polygon2 = array(10,30,40,20,80,30);

/*
vector shit
*/

//vector a
$va_x = $polygon2[2] - $polygon2[0];
$va_y = $polygon2[3] - $polygon2[1];

//vector b
$vb_x = $polygon2[4] - $polygon2[2];
$vb_y = $polygon2[5] - $polygon2[3];

//vector a length
$va_length = sqrt(($va_x*$va_x)+($va_y*$va_y));
$vb_length = sqrt(($vb_x*$vb_x)+($vb_y*$vb_y));

//vector e
$ve_x = (-$va_y/$va_length) * 10;
$ve_y = (-$va_x/$va_length) * 10;

//g-spot
$sG_x = $polygon2[0]+$ve_x;
$sG_y = $polygon2[1]+$ve_y;


/*
K here...
*/

//this is n vector
$vn_x = $polygon2[2] - ($va_x/$va_length) + ($vb_x/$vb_length);
$vn_y = $polygon2[3] - ($va_y/$va_length) + ($vb_y/$vb_length);

//t number
$mt = (($vn_x * ($polygon2[3]-$sG_y) - $vn_y * ($polygon2[2] - $sG_x)) / ($va_y * $vn_x - $va_x * $vn_y));

//k-spot
$sK_x = $sG_x + $mt * $va_x;
$sK_y = $sG_y + $mt * $va_y;

User avatar
totem
39mins club
Posts: 328
Joined: 26 Dec 2007, 14:04

Re: Programmer needed (level generator)

Post by totem »

i don't want to confuse people but here is the way i did :


1. See a pipe as a path :

Image

2. For each section, find the ortho vectors of each extremity

Image

3. Given a width, compute intersections between the interesting lines

Image

4. You have a pipe dude

Image

result :

Image
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Thank you for not confusing =D But anyways, that was the way I first wanted/tried to do it but I couldn't figure out how to do the other lines so that I could actually count the point where they intersect. Like how teh fuck you do that? There was a time when I was king of maths, but apparently not anymore! I feel like a retard when thinking these things, not sure should I be happy or sad =)
User avatar
totem
39mins club
Posts: 328
Joined: 26 Dec 2007, 14:04

Re: Programmer needed (level generator)

Post by totem »

it's all matter of 2D points and vectors :

Image


then :


Image
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Ok here is the random update teh:

- You can make the lev either uphill or downhill
- Apples on/off
- Killers on/of with different "difficulty" (noone liked killers on so don't balle it too much =)

http://gen.oktobia.org/

Maby now I will move forward and leave even the pipe shit behind at least for now xD
User avatar
Xiphias
39mins club
Posts: 4101
Joined: 23 Nov 2004, 23:05

Re: Programmer needed (level generator)

Post by Xiphias »

woooooooow =o where did you find those seconds of spair time? XD
Thorze wrote:I just wanted to make a cool topic like Juish have cool topics..
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

I finished another thing I've been busy with =) And now I have thousands of seconds to develope this, unless I start making my other project soon =D
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Made teh rah mode =) It's quite experimental and not that random, and prolly sucks but I wasted waaaay to much time making it so there it is:

http://gen.oktobia.org/rah

So be careful what level you download, some might cause elma to crash (if polygons intersect).

Does someone want some new mode to be made, and what mode? Or ideas to make ruh or rah even better?
User avatar
Xiphias
39mins club
Posts: 4101
Joined: 23 Nov 2004, 23:05

Re: Programmer needed (level generator)

Post by Xiphias »

If there was a Like button I would so press it! :D:D:D
I gotta check the levels later on after my homework (or tomorrow). Looks like you cheated and put somewhat fixed locations (+- some minor differences) for each polygon and the rotation and size of the polygons differ not very much :D
I like how you handled the "background" level problem.

Good job Ville =)
I'll try to come up with some new idea for your randomnessorized level generator script.
Thorze wrote:I just wanted to make a cool topic like Juish have cool topics..
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

Yes I had to xiit like that because I couldn't come up with nice algorithm that wouldn't create platforms too close to each other. If anyone has any idea, you can suggest. But plz no "Just count the distance of each lines to every existing vertex and if too close then..", nat gonna happen. I made a script to detect intersections but there was some tiny bug (or then I somehow passed few wrong variables in it, who knows) so I couldn't use it yet, but maby laters. And ofc it does not solve the platforms being too close...
User avatar
Kopaka
39mins club
Posts: 6612
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Programmer needed (level generator)

Post by Kopaka »

When I press generate it just goes to a blank page.
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Programmer needed (level generator)

Post by ville_j »

This is a problem of the host. Ftp isn't working correctly atm and I can't update any files. I tried to update the generator script and that happened. I guess it will be fixed by tomorrow when I am able to re-upload the files.

edit.
Oops it was my mistake after all, didn't include the functions I made. Anyways sucks host because it doesn't tell me what is actually wrong =)

So, AH's are more random now. It may still generate intersecting polygons though. I've just started to rewrite my generator with classes so in the future it will be easier for me to develop it I hope.
User avatar
Kopaka
39mins club
Posts: 6612
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Programmer needed (level generator)

Post by Kopaka »

Wow, suddenly this is a really interesting project :) Before with uphills and the talk about pipes I thought it was kinda useless since it was only what I consider bad/no fun levels, but now it can create some levels that could be fun to play. Good work =)
sunl
Kuski
Posts: 346
Joined: 27 Jul 2013, 16:23

Re: Programmer needed (level generator)

Post by sunl »

Anyone have copy of level format & algorithms? I think Lousku posted somewhere on mopolauta and can't find it, and file link here is broken

CHeers
User avatar
Lousku
Kuski
Posts: 2925
Joined: 5 Feb 2010, 00:25
Team: BAP
Location: expensive land of dads

Re: Programmer needed (level generator)

Post by Lousku »

sunl wrote:Anyone have copy of level format & algorithms? I think Lousku posted somewhere on mopolauta and can't find it, and file link here is broken

CHeers
http://zzz.ink/elma/formats/
then again i don't know anything
maybe easier not to think abouut alöl things thought than not things thought ... or something..=?
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Programmer needed (level generator)

Post by Zweq »

it wos for mats not for sunl..
Image
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Re: Programmer needed (level generator)

Post by skint0r »

Started "transcribing" those text files here btw with little explanation, but still work in progress: http://wiki.elmaonline.net/Technical
Prestigious member of 14.6x Tutor14 club
Post Reply