Randomly Generated World

Get help using Construct 2

Post » Mon Sep 12, 2011 6:23 am

is there a way to have a world randomly generated when the game starts, and then to keep that world and its info around (yes a save game)? The way I imagine my game is in a manner not that unsimilar to Civilization, a scrolling flat world.

Also can I use construct to port the game from HTML5 to say C++ easily?
B
4
G
2
Posts: 44
Reputation: 1,088

Post » Mon Sep 12, 2011 7:05 am

You could use something like:

floor(random(1,4) to generate a number that would relate to your world.

For example, If you called your worlds:

world1
world2
world3
world4

You could do this to capture the name of the world:

"world" & floor(random(1,4))

The result would be something like world1, world2, world3, world4. You can then concatenate that to a URL like this:

http://localhost/" & object.property

If you were to stuff the value in a text box, you could do something like this using the Browser object:

Go to "http://localhost" & Text.Text in a new window("NewWindow")

The result of the above would be something like this:

http://localhost/world2/

Just make sure you have a corresponding directory on your server. In this case, a directory called world2 with the index file in there.

You would need a way to fire that event, for example a button. It cold be anything. Even a portal or something.

In terms of storing the variables, you could use an Array object.
B
18
S
8
G
7
Posts: 120
Reputation: 5,625

Post » Mon Sep 12, 2011 7:41 am

So what you're saying is that I have to have world's premade and can set some events so that a specific world spawns when specific variables are chosen? At like a load up screen?
B
4
G
2
Posts: 44
Reputation: 1,088

Post » Mon Sep 12, 2011 7:46 am

[QUOTE=Crazedgoalie56] So what you're saying is that I have to have world's premade and can set some events so that a specific world spawns when specific variables are chosen? At like a load up screen?
[/QUOTE]

This is one way of doing it and yes a premade world. Unless you've got some crazy algorithm that will automatically create your worlds on-the-fly, which would be pretty cool.

The load up screen could be where the random event gets fired.
B
18
S
8
G
7
Posts: 120
Reputation: 5,625

Post » Mon Sep 12, 2011 7:52 am

OK Shoot. I was hoping someone had already figured out some kind of crazy algorithm to create a random world ;)

I guess for now I will stick with premade worlds.

I have plans to eventually move this over to a C++ coded game to make it a bit more inclusive because I have this really great idea that I think would sell well. but I think for the indev stage I will keep it as an HTML5 game.
B
4
G
2
Posts: 44
Reputation: 1,088

Post » Mon Sep 12, 2011 8:04 am

In full disclosure, I am by no means an expert with Construct 2, I just finished the tutorial a couple of hours ago. So someone out there may have created an random level generator or something.
B
18
S
8
G
7
Posts: 120
Reputation: 5,625

Post » Mon Sep 12, 2011 8:09 am

Well I will mess with it when I don't have to devide my attention between the game and class!

Thanks for the help though, I think that premade worlds would be easiest for now. I can set up a menu system where each variable sets up a chain of events and a map is created in the end.
B
4
G
2
Posts: 44
Reputation: 1,088

Post » Mon Sep 12, 2011 10:50 am

[QUOTE=Crazedgoalie56] is there a way to have a world randomly generated when the game starts[/quote]
Your generating events will have to be in the "Start of layout" event of the "world layout".

[QUOTE=Crazedgoalie56]and then to keep that world and its info around (yes a save game)?[/quote]
You could have used webstorage, but the plugin is broken/not up to date apparently.
One solution might be to export your datas to a website, but this might be too complicated for a beginner.


[QUOTE=Crazedgoalie56] The way I imagine my game is in a manner not that unsimilar to Civilization, a scrolling flat world.[/quote]
Tiles, right ?
Have a square sprite containing your textures in a single animation.
Create instances of this sprite, covering your layout.
You can use the random function to set which animation frame to display.
Check the capx

[QUOTE=Crazedgoalie56]Also can I use construct to port the game from HTML5 to say C++ easily?[/QUOTE]
I doubt it.
HTML5 is based on Javascript. Your project is done as xml/JS. There's no "easy" way to convert to C++ as those languages has nothing to see one with the other.
In this case, use Construct-Classic which exports .exe. (but still you won't obtain C++ sources).
In the end, if you want to use C++ than you are defeating Construct's purpose, so I'd suggest you to make sure of what you really want to do and documentate yourself about what JS and C++ really are.

Anyway, for you and Genghis, I'd suggest starting with easier projects (to get used to C2), and reading some more tutorials/practicing more with C2/CC.Kyatric2011-09-12 10:52:06
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Sep 12, 2011 11:12 am

Alright that is incredibly helpful. I just found this tutorial on here about making the tile sprites show up randomly everytime so OI am going to follow that. Otherwise, I think what I want to do is eventually have it so that you can use this without a web browser, in a .exe format (though I would settle for Java if it was easier). And I can't seem to find a good development studio for it (Unity is too complicated for what I want to do at this point). I just want to know if there is an easy way to bring a game which was created in Construct and convert it to say C++ or Java or something.
B
4
G
2
Posts: 44
Reputation: 1,088

Post » Mon Sep 12, 2011 11:33 am

[QUOTE=Crazedgoalie56]I just want to know if there is an easy way to bring a game which was created in Construct and convert it to say C++ or Java or something.[/QUOTE]

No.
Construct-Classic will export to exe. Construct2 will export to HTML5 (for now).
That's all.

If you want to use C++, you'll have to program the whole thing in C++.
If you want to use java, you'll have to program the whole thing in java.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Next

Return to How do I....?

Who is online

Users browsing this forum: suicidenutella and 0 guests