Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Terraria world generation  (Read 647 times)
0 Members and 1 Guest are viewing this topic.
Offline kingroka123

JGO Knight


Medals: 22
Projects: 3
Exp: 10-12 months


Gamer's Helmet


« Posted 2013-06-04 06:09:17 »

i have a terrarian style terrain engine but it runs extremly slow. my engine only renders whats on screen. there are individual blocks being spawn. so my question is, how can i get my frame rate as high as in terraria? btw my engine is 2d

- thanks

Offline jh62

Senior Newbie





« Reply #1 - Posted 2013-06-04 07:09:23 »

Can you show some of the code you use for rendering and stuff?

Offline Zhon

Junior Member


Medals: 4



« Reply #2 - Posted 2013-06-04 16:27:23 »

Correct me if I'm wrong, but Terraria generates the whole world on the first time it is created, still on the menu, it takes a long time to generate it, but when you're actually in game, no generation occurs. Does this apply for your game?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kingroka123

JGO Knight


Medals: 22
Projects: 3
Exp: 10-12 months


Gamer's Helmet


« Reply #3 - Posted 2013-06-04 17:25:39 »

Correct me if I'm wrong, but Terraria generates the whole world on the first time it is created, still on the menu, it takes a long time to generate it, but when you're actually in game, no generation occurs. Does this apply for your game?

Yes it does actually. everything is calculated before gameplay happens

btw here is the code for my generation
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
   r=new Random();//just a random to help generation
        decider=r.nextInt(5);//how jagged the terrain  will be
       
            //there are no chunks actually being rendered, chunkSize is just a number
//the blocks are just doubles holding simplex noise data
        for( x=0; x<chunkSize*25; x+=16){
            for( int k=0; k<chunkSize*2;k+=16){
         block1=SimplexNoise.noise(x/2,0);
               block2=SimplexNoise.noise(x/4,0);
               block3=SimplexNoise.noise(x/8,0);
               block4=SimplexNoise.noise(x/16,0);
              block5=SimplexNoise.noise(x/32,0);
         
                  y =  (block1+block2+block3+block4+block5*(decider+1);

                     
                  if(k<4){//this just decides which type of block each tile is
              blok=1;
                  }
               if(k>4&&k<4*5){
                  blok=0;
               }
               if(k>4*5){
                  blok=2;
               }
               addBlock(new TestEnt(x,y+595+k, blok));
               
               
            }
         }


Each testEnt is stored in a linked list then created. each blocks checks to see wheter it is off the screen or not then doesn't render accordingly

Offline Mike

JGO Ninja


Medals: 69
Projects: 1
Exp: 5 years


Java guru wanabee


« Reply #4 - Posted 2013-06-04 17:56:05 »

What engine do you use? For fast 2D you should look into libGDX.

Mike

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline kingroka123

JGO Knight


Medals: 22
Projects: 3
Exp: 10-12 months


Gamer's Helmet


« Reply #5 - Posted 2013-06-04 18:16:52 »

i use the regular java2d but ive pretty much fixed it. i was running the functions of the blocks way to much

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 121
Projects: 4
Exp: 3 years



« Reply #6 - Posted 2013-06-04 19:43:56 »

Maybe it only renders what's onscreen, but it's still calculating what's offscreen...
Offline Andre Lopes
« Reply #7 - Posted 2013-06-04 19:47:15 »

In terraria it sures calculates whats offscreen, because if u push a pipe of one side of the world to the other side, you can transport water blocks Tongue
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (81 views)
2014-04-15 18:08:23

BurntPizza (73 views)
2014-04-15 03:46:01

UprightPath (84 views)
2014-04-14 17:39:50

UprightPath (67 views)
2014-04-14 17:35:47

Porlus (83 views)
2014-04-14 15:48:38

tom_mai78101 (107 views)
2014-04-10 04:04:31

BurntPizza (167 views)
2014-04-08 23:06:04

tom_mai78101 (263 views)
2014-04-05 13:34:39

trollwarrior1 (213 views)
2014-04-04 12:06:45

CJLetsGame (223 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!