Java-Gaming.org Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (681)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (744)
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 1497 times)
0 Members and 1 Guest are viewing this topic.
Offline kingroka123

JGO Kernel


Medals: 109
Projects: 9
Exp: 3 years


Gamer's Helmet


« Posted 2013-06-04 04: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 05:09:23 »

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

Offline Zhon

Junior Devvie


Medals: 4



« Reply #2 - Posted 2013-06-04 14: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 Kernel


Medals: 109
Projects: 9
Exp: 3 years


Gamer's Helmet


« Reply #3 - Posted 2013-06-04 15: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 Spiffy Duke »


Medals: 148
Projects: 1
Exp: 6 years


Java guru wannabe


« Reply #4 - Posted 2013-06-04 15: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 Kernel


Medals: 109
Projects: 9
Exp: 3 years


Gamer's Helmet


« Reply #5 - Posted 2013-06-04 16: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: 167
Projects: 5
Exp: 3 years



« Reply #6 - Posted 2013-06-04 17: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 17: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.

 
CopyableCougar4 (55 views)
2016-06-25 16:56:52

Hydroque (89 views)
2016-06-22 02:17:53

SwampChicken (90 views)
2016-06-20 13:22:57

SwampChicken (92 views)
2016-06-20 13:22:49

SwampChicken (85 views)
2016-06-20 13:22:26

Hydroque (129 views)
2016-06-15 08:22:50

Hydroque (123 views)
2016-06-13 06:40:55

DarkCart (240 views)
2016-05-29 02:30:33

Hydroque (205 views)
2016-05-26 14:45:46

Mac70 (188 views)
2016-05-24 21:16:33
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17
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!