ScratchData LogoScratchData
Back to andymwat's profile

Tile Scrolling / World Generator (WIP)

ANandymwat•Created January 26, 2015
Tile Scrolling / World Generator (WIP)
62
54
1392 views
View on Scratch

Instructions

Change the terrain generation variables to whatever you want, and then press space. Use the arrow keys to move the camera. PLEASE NOTE: This is not done. It still needs many more improvements and optimizations. --Technical stuff below this point-- The terrain is stored in a list named "TileData". Each item of the list is a new x position, and every 3 letters of an item is a tile. This means that this engine can support up to 999 different tile types. I might change this down to 2 characters (99 variations), which may be a bit faster. The terrain is generated at the beginning, using a custom block which allows you to specify average height, variation (jaggedness of terrain), and terrain length. Larger values for the length cause it to take longer to generate the terrain. However, it works quite quickly with very high values (50,000 is default). The terrain is controlled by the local variable TempHeightMod. As it generates terrain, this value moves randomly up and down. How large it is determines the slope of the terrain. Each frame, the engine tests for keypresses, and then renders the tiles. When it renders the screen, it takes into account the current camera scroll x (not y, it assumes the terrain will be horizontal), and then renders everything that will be on screen. It stops trying to render when it detects that what it is rendering is outside of the Render Distance. By default, the render distance is 9, just enough to render everything on screen, but low enough to maximize speed. If needed, this can be reduced to increase speed, but some tiles on the edges will not be rendered. The newest version of the engine supports zooming the camera. This is controlled by the Camera Zoom variable, and affects the size of all of the tiles. Also, it now controls the render distance, so zooming in more will drastically increase speed. This also means that zooming out will make the game run MUCH more slowly.

Description

This is a test for a tile-based scrolling engine. The "terrain" is made of differently colored tiles which are randomly generated. Keep in mind that while this tile-scrolling engine can be used for any tile-based games, it's optimized for horizontal scrollers. Newest Additions: -Added Ore generation! As of right now, there is only two types of ore, and its generation can be controlled by the "Ore Generation" variable. The number is the percent of stone blocks that are replaced by ore. -Added camera zooming! Control this with the "Camera zoom" variable. WARNING: low camera zoom values can be VERY slow on weaker computers To-do list: -Make tiles enter and leave the screen more smoothly (No disappearing) -Optimize

Project Details

Project ID44877466
CreatedJanuary 26, 2015
Last ModifiedFebruary 15, 2020
SharedJanuary 28, 2015
Visibilityvisible
CommentsAllowed