Terraria Clone

Show us your works in progress and request feedback

Post » Fri Mar 07, 2014 4:01 am

Very nice. Are you updated to tilemap in the last update? I try it using Firefox and the game is fine.
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Fri Mar 07, 2014 10:19 am

No still using a single sprite object for all of the terrain. Been working on some other stuff such as the inventory so I haven't had a chance to learn tile maps just yet.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Sun Mar 09, 2014 11:04 am

Can you explain a little more how you create a the terrain? I'm novice with that. With an array maybe?
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Sun Mar 09, 2014 12:54 pm

Is the terrain infinite?
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Mon Mar 10, 2014 5:06 pm

How I created the Terrain. I followed a really great tutorial, Procedural Generation for Beginners Tutorial by abhilash2863. Full credit goes to him for an awesome PDF he put together on procedural generation.

Create an Array.
Assign each X & Y element a random integer from 1-20.
Assign each X element in the Y element 0 to integer 21.
If an elements number is less than 13 create object Terrain and set animation to dirt.
If an elements number is 14-18 create object Terrain and set animation to rock.
If an elements number is 19-20 create object Terrain and set animation to gold.
If an elements number is 21 create object Terrain and set animation to grass.

Image

All of this runs on Start of Layout so every time the level is loaded this runs and assigns new random numbers excluding the top of the Terrain which is always set to 21 which will be grass. The underground however is always randomly generated so it will never be the same.

So with a single sprite object, Terrain, I was able to assign it multiple animations. Animation Rock, Grass, Dirt, Gold, and each animation is a single frame of Grass, Rock, Dirt, or Gold. I was then able to assign instance variables to the Terrain object. GoldHealth, DirtHealth,GrassHealth, and RockHealth. When you hit something the events check to see which animation is currently playing if it is currently playing rock animation and you hit it then subtract 1 from rock health. If Rockhealth is equal to 0 then destroy Terrain object. So on for the rest excluding gold in that is GoldHealth = 0 then destroy Terrain object and add 1 to a Global Variable called Gold. Which is a counter that keeps track of how much gold you currently have.

Image

So that's pretty much the main bulk of the Terrain code.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Mon Mar 10, 2014 5:08 pm

vagaev wrote:Is the terrain infinite?


No this Terrain is not infinite it is a pre-determined size set by the size of the array. Making an infinite terrain would be difficult I think in that you'd have to be creating objects on the fly as they appear on screen and destroying them as they went off screen.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Mon Mar 10, 2014 7:47 pm

Yes but isn't there a way to set up procedural infinite terrain generation. In x axis and y axis. Like in spellbound/terraria..
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Tue Mar 11, 2014 4:53 am

I have not played spellbound, but I have played Terraria and the map size is not infinite it is just quite large. But there is an end to it. As far as setting up an infinite procedural terrain in construct I would not know how to go about accomplishing that. I mean I know you'd have to be destroying anything that goes off screen and creating things on the fly when they came on screen. But that lends itself to the issue of a constantly refreshing world where no changes you make stick. To my knowledge there is no game that has an infinite world that never ends and saves changes made to that world. I don't even think it would be possible. To make an infinite world you would need an infinite amount of ram and storage place to hold all that data.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Wed Mar 12, 2014 5:21 am

Cool little game. Is the terrain randomly generated?
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Wed Mar 12, 2014 1:56 pm

@Tekniko the top grass will always be the same but the underground is randomly generated everytime.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

PreviousNext

Return to Works in Progress/Feedback Requests

Who is online

Users browsing this forum: No registered users and 3 guests