The Game Creators Newsletter Issue 28Welcome to the April edition of our newsletter. This month The Game Creators had our company-wide meeting where we discussed the current projects and how things should progress for the future. A few important decisions regarding licenses were made that will be good news for all you SDK and FPSC users - in a nutshell, we're dropping them. All games made with FPSC V1 will be free of all licenses, so you can sell them without restriction. The games also won't feature splash screens at the end either. As for the Dark Game SDK we're dropping the shareware license totally and converting it to a Full Commercial license with NO restrictions on what you can sell or earn with it. For more details please see the SDK 1.1 and FPSC News articles respectively. There are quite a few new games tested this month including the rather cool MoxBlox and my personal favourite Katey's Quest. You can find all of those in the Games to Test section. While not directly TGC related we were also interested to see the first signs of the X-Box 360 design, a topic currently being hotly debated on our forums. I wonder, does this mean a Halo 360? Highlights this month include another superb PC Extreme article, two brand new DBPro tutorials, stacks of new releases, games and forum chatter. Until next month, have fun. ContentsDarkBASIC Professional Upgrade 5.8After an intensive bout of bug fixing and upgrading the new 5.8 release for DarkBASIC Professional is now available for free download. This release fixes a large number of issues, including nearly all of those reported on the forums, and introduces a large set of new commands including features such as object saving, vertex data manipulation, CSG commands and a brand new Shadow Shading option. The Debugger was also updated and will now track and step through code accurately. As well as enhancements to the core language updates were also made in the Cloth and Particles pack and the Enhancement Pack. Finally the DarkBASIC Professional Object (DB0) file format specification was officially released. Please note that as with previous Upgrades you must have DirectX 9.0c installed. For those of you who participated during the beta test of 5.8 please note that the final release does NOT require the DX SDK DLLs to be present and will work with the standalone 9.0c release. You can download the Upgrade, an Examples source code package containing code snippets and examples for all new features and fixes in 5.8 and the DBO specification from the page below. Upgrade 5.8: //www.thegamecreators.com/?m=view_product&id=2000&page=upgrades TGC Question and Answers Session Chat LogOn Sunday the 27th of March The Game Creators held a Question and Answers session in the DarkBASIC IRC channel. Lee Bamber, Mike Johnson and Dave Milton were present and answering your questions about all things DBPro. You can now read a log of the chat session, compiled by John Vidler. TGC Chat Log: tgc_chat_log_27thMarch.html Dark Game SDK 1.1 Update and License ChangesThe Dark Game SDK has received a major upgrade based on the 5.8 fixes and other changes specific to the SDK itself. Just as important however is that we are also changing the license restrictions on the SDK.
SDK UpdatesVersion 1.1 of the SDK brings about a host of new changes including (but not limited to): Linker fixes for all of the sprite functions, crash prevention in functions such as dbGetTextureNonLocalVideoMemory and Collision against sphere objects, .X files can be loaded with their vertex colours taken into account, material diffuse/ambience/etc changes now work across multi-material objects. There are speed increases including deleting objects that have shadows, dotproduct3 bump mapping returns, a new texture flag allows cube maps to be loaded directly, camera angles have been modified for free-flight mode and plenty more changes. The SDK is a free download to all registered customers and will be available from the 27th of April onwards, simply go into your Order History and grab the new file there.
SDK License ChangesIt was decided that the licenses that come with the Dark Game SDK will now change. Traditionally we offered a Freeware license and a Shareware game license (with no provision for a commercial release). We are keeping the low-cost Freeware license as it serves as a great introduction to the SDK, but the Shareware license is changing to a full un-restricted Commercial license. That means that you are free to sell anything you make with the Dark Game SDK with no restrictions at all (just as with DarkBASIC Professional). There will be no increase in price either. All current Shareware license holders will be upgraded to the Commercial License free of charge. This change will take place on the Dark Game SDK website in the coming weeks.More details here: //www.thegamecreators.com/?m=view_product&id=2128 FPS Creator NewsAs reported last month we've been hard at work implementing a very cool physics and debris system into FPS Creator. This will be included in the Version 1 release and it will not cost any extra money. The new physics system allows for a completely new form of gameplay and level design. Players can pick-up objects (you assign the weight of objects directly in the editor) and throw / place them, which means you could force a player to construct a bridge across a lava stream by picking-up and laying down planks of wood. Other changes include a new debris system - so shooting a crate or bottle will force it to shatter into pieces that crash realistically around the level (all using physics). There are also a whole set of superb new sound effects to replace the gun effects currently in FPSC EA. These new effects pack a real sonic punch and give a whole new sense of realism to the engine. With the introduction of physics you can of course now push objects around, which meant we had to carefully explore the sound an object would make as it slide across the floor or was dropped. These new material sounds are now in - pick up and throw a metal rod around and it will clang accordingly, shove a wooden box across the floor and it'll grate depending on the floor surface. It all helps beef-up the realism of the games you create.
New LicenseAt a recent TGC conference one of the most exciting things we agreed upon was that there will be NO commercial restriction or license required for any game you make with FPS Creator. We will also be removing the splash screen in the V1 release from the end of your games. This means you will be able to sell any game you make with FPS Creator and not have to pay us a single penny beyond your initial purchase of the software.We know that a lot of people were worried because we had not decided what the "commercial" restrictions were going to be. Many of you assumed that we'd follow a similar route to The 3D Gamemaker where a commercial license cost in the region of $500. But this was all just speculation and we consistently said for months that we had not yet decided what course of action we would take - this is now over and you can build your games with FPSC V1 safe in the knowledge that if you create a really stunning title you're free to sell it. If that combined with the new physics engine is not a great enough incentive to buy FPS Creator then we don't know what is! :)
Screen Shot CompetitionAlthough time has nearly run out for the month of April we are offering no less than $500 for the best screen shots submitted on our web site! There are no limits on the number of times you can enter and you can create the screen shot with either the full EA release or the trial version of FPS Creator. All we ask is that it features media that we supplied or that *you* own copyright over (so don't go sticking in models ripped from Call of Duty please!). Full details can be found here: //www.thegamecreators.com/?m=view_product&id=2001FPS Creator EA Release is available to buy now for only $56 (€43, £30) with a heavily discounted upgrade path to Version 1 when released this Summer. More details here: //www.thegamecreators.com/?m=view_product&id=2001 PC Extreme - Graphics Card Workshop - Feature CreepThis is the second in a new series of articles from the talented tech gurus over at PC Extreme magazine. Each month they'll delve into a current or emerging PC technology, always with a gaming / development related theme. This month: Manufacturers love to list features, says Wil Harris, but what do they actually mean? He explains in-depth. With the graphics card market being of such a high value, companies like Nvidia and ATI spend an awful lot of money making sure customers believe that their products are better than their competitor's. To razzle and dazzle, marketing executives come up with all sorts of fancy names for the technologies that power the cards, in the hope they'll sound more impressive than others and will hook into buyers' minds. In this month's workshop, we will go through some of the features that graphics companies tout as being major selling points for their cards, explaining what they are and how they differ from features offered by their rivals.
Nvidia PureVideo employs video shaders, which are a similar concept to shaders in 3D graphics. Video shaders are arithmetic operations that generally operate at a perpixel level. As with 3D shaders, video shaders are fully programmable, so that support can be added for other features or file formats down the line. Motion estimation is one of the most computationally intensive aspects of video processing and accounts for over 50% of the CPU workload when encoding video in a format such as Windows Media. Motion estimation is used to calculate motion vectors, a key part of the file format used to encode video in formats like WMV9 and MPEG4. Rather than processing frame after frame after frame, these encoding systems use one frame of data and then a recorded motion vector to move the data appropriately for the next frame. Using motion vectors allows for better quality video at a lower file size, and the hardware processing in PureVideo allows for better encoding and decoding performance. The final key element of PureVideo is that it accelerates next-generation Windows Media high definition content in hardware, leaving the processor free to do other tasks. It also accelerates the latest generation of Windows Media 10 content, which is a big plus for future proofing. The DXTC compression is far lower than the normal map compressed with 3Dc
Shadows High Dynamic Range (HDR) lighting is a type of lighting supported by the GeForce 6 series, and is a way of making bright things look brighter and dark things look darker, while retaining the details in both (and without making a scene difficult to view). HDR allows for luminance and radiance beyond the standard range available in most software today. There are lots of ways of doing HDR but the standard supported by the industry at large is OpenEXR, which was invented by the special effects wizards at Industrial Light & Magic for movie production. To handle the lighting calculations and display the values correctly, HDR requires that programmers use floating-point calculations everywhere for optimum precision. That means floating-point arithmetic, blending, filtering and textures. True HDR even requires a display capable of showing such a wide range of colours, but these aren't really on the market yet. Currently, HDR lighting is best seen implemented in Far Cry, where the effect of switching it on is noticeable and transforms the graphical experience of the game.
ATI With normal maps being used in top titles like Half-Life 2, Doom 3 and Far Cry, and set to become even more essential with the new iteration of Unreal technology, 3Dc is looking like it'll be an essential feature in the future. An antialiasing algorithm exclusive to ATI is Temporal Antialiasing. This works in a slightly different way to standard 2x/4x/8x multi-sampling techniques. The reasoning behind temporal AA is that as frame rates approach the refresh rate of your display device - such as 60 FPS for most LCD monitors - additional frames are of little use. The persistence of the display as the frame rate increases causes two frames to be viewed effectively as one. 4xAA takes four points to create the sample used. Temporal AA works by taking two samples in frame one and a different two samples in frame two. When the frame is displayed on the monitor, the eye finds it difficult to distinguish between the two frames - bearing in mind it is seeing 60 every second - and sees what looks like a 4xAA image. However, the performance impact is only the same as 2xAA, providing an increased image quality for no loss in frame rate. As the frame rate drops, the differences between the two frames can become more obvious, destroying the illusion. In these cases, the ATI driver is able to switch down to standard antialiasing until the frame rate rises again.
Hyper Z HD Using Hierarchical Z, the ATI card can judge which image components are in front of others, therefore calculating which objects will be seen in the final rendered image and which will be partially or completely hidden. By using Z compression, the data going in and out of the Z-Buffer can be compressed and uncompressed quickly, achieving up to 8:1 compression. The ATI architecture also uses Z-buffer techniques to speed up the calculation of stencil shadows, which often store information in a similar way to the Z-buffer.
TurboCache vs HyperMemory Both ATI and Nvidia claim that theirs is the better-performing solution, but there are plenty of factors to consider, such as price and form factor, before performance (after all, neither of these technologies are really appropriate for an average PC Extreme reader). However, for knocking together a system for a friend or relative, these cards can give you a real advantage in video processing and gaming capabilities for very little cost - both can be bought for under £50 in their basic configurations and work without a fan for quiet operation. In testing, we have seen a GeForce 6200TC run Doom 3 at 640x480 with playable frame rates, and we saw perfectly acceptable gameplay at 800x600 on Half-Life 2, with details turned down - amazing for less than 50 notes!
When buzzwords attack!
Unique? With HDR, you can see that the colours on the left of the screen are more intense; the dark colours are darker and the greens are greener (click for full-size shot) HDR lighting is currently only supported by Nvidia's drivers, but it is also available - theoretically - on ATI hardware. Whilst ATI's cards have all the technical requirements to support HDR, they work to a different specification of the standard, whereas the rest of the industry works to OpenEXR, as mentioned. Either ATI is going to have to implement some form of OpenEXR rendering with its drivers or the rest of the industry is going to have to change to suit - which we think is rather unlikely. Hyper Z is an ATI buzzword but it is important to note that Nvidia's hardware does a very similar thing with its architecture - Z occlusion and culling has become a crucial feature for any 3D hardware, and ATI certainly doesn't monopolise it. Likewise with 3Dc - Nvidia hardware supports dedicated normal map compression but just doesn't advertise the ATI-promoted standard. PC Extreme magazine is available monthly: http://www.livepublishing.co.uk/pcextreme/ Sound Essentials DVD VolumesThe Sound Essentials DVDs provide an enormous range of top-quality produced stereo samples covering a wide range of genres: from Hip Hop and UK Garage to 70s Funk, Disco, Synths, Sound Effects and more. Each DVD is packed with thousands of 44.1KHz 16-bit samples, all ready for you to use in your games - license free.
BlueIDE 1.01 ReleasedThe latest version of the BlueIDE editor for DarkBASIC Pro is now available. This version mainly consists of bugfixes and other enhancements. Download from the website below and then extract both folders in the zip file to your hard drive, and if you have not installed BlueIDE before, you will need to run the batch file inside the "System Files" folder. To start the editor, run "blue.exe" from the "BlueIDE Build" folder.For those who have not used BlueIDE before, here is a quick list of the most useful features:
Download BlueIDE: http://blueide.sf.net DBPro Tutorial - Asset ManagementThis month author Steve Vink takes us on a spring cleaning tour and talks about Asset Management. This is a shorter version of the tutorial, the full length verison can be downloaded - details at the end. Last week, I cleared out the wardrobe and threw out some old clothes. Checking the pockets of a jacket I haven't worn for three years, I found a ten pound note (18.7 USD, 14.6 EUR). I don't know when I put there; I don't know why I put it there. In fact, due to the lack of a wallet, I couldn't tell you what was in my pocket now, which pockets have cash in, or if I have any money at all. Thankfully, my program code is a great deal more organised. Everything has it's place, and I can find it in an instant. Assets cover a multitude of "things". An asset could be a character, a place, a planet or a wallet. Assets have many characteristics, which you might define like so: AlienName$ = "Vinste Hudke" AlienLegs = 1 AlienArms = 3 ... This is fine for one alien, but if you want to make 10 aliens, you'll soon burn the midnight oil generating variable names, populating them, and processing them when the action starts. Let's start to lay the foundations of a more efficient way to make a scalable world, where the program code does not impose limitations on your imagination. Dark Basic Professional provides you with Types to store and retrieve this information. A Type is characterless, until you create it. I want to make an alien, so I'll create a type, tAlien: type tAlien name$ as string legs as integer arms as integer mass# as float strength# as float health# as float endtype Now I have a Type which describes the basic elements of my alien. Before I can use it, I need to make a variable of type tAlien. global MyAlien as tAlien Just as I can create strings and integers, my program now recognises tAliens as a type of data. Now I can define my alien: MyAlien.name$ = "Vinste Hudke" MyAlien.legs = 1 MyAlien.arms = 3 MyAlien.mass# = 3400.0 MyAlien.strength# = 100.0 MyAlien.health# = 100.0 Vinste Hudke is lonely. I could create a second variable of Type tAlien and make a friend for Vinste, but there is a better way. Arrays can be created from your own Types. Just as you can make a 10-element array of integers, you can do the same for tAliens. Dim MyAlienFamily(4) as tAlien I can now define 4 members of my alien family in the array. In this case, they all have the same number of legs and arms, so I can already take advantage of my well designed structure: For n = 1 to 4 MyAlienFamily(n).legs = 1 MyAlienFamily(n).arms = 3 next n To put this in perspective, you might want an army of aliens. Whether you want 1 or 1000, the number of lines required to make your basic alien is the same. Each alien is an individual, so their health and strength can change independently over the course of your game. Within a loop, the same line of code can interrogate all 1000 aliens, because the Array / Type structure facilitates a consistent method. You may not have considered this yet, but we have been very broad with our definition of the Type tAlien. I could now create a second family of aliens, using a new array but of the same Type. This family could be much bigger and far less healthy due to the fact that they can pick up more burgers with their 15 arms. But we can still "process" them with the same functions in our program, because they have the same set of characteristics. That, I would say, is Food For Thought. This month's download includes a mini demonstration to help you get to grips with Types within Arrays, and putting them into practice. The program defines, creates and characterises twenty unique aliens, across two tribes. Using only a small routine, it pits the two tribes against one another, displaying the ensuing battle on-screen as text and health bars. It concludes by displaying the winning tribe, and the number of aliens left standing. Excluding comments, the entire scenario is enacted in less than 80 lines of code, thanks to our efficient implementation of the program assets.
Until next time, happy Coding! Note: This tutorial has been packaged up into a nice friendly installer that will load a full-length (more detailed) version of the tutorial, along with DBPro source code into your Start Menu (in The Game Creators program group). Each month this collection will build-up into a formidable free resource. Download this tutorial + code: DBPro_April_Tutorial.exe Mono hits CNet Download.comCongratulations are in order to the guys behind the excellent shooter Mono. It was our issue 25 cover game and it appears we're not the only ones to love it. The editor at the massive CNet website Download.com obviously took the colourful blaster to heart awarding it a 5-Star Editors Pick, making it one of the Top Rated games on their site - which we're sure helped lead to over 12,500 downloads! So just another great example of what real programmers can do with DarkBASIC Professional. Download Mono from: http://www.download.com/Mono/3000-2099_4-10379807.html On-line DBPro Help FilesOne of the forum moderators has set-up a site where DBPro users can create their own version of the help files. There is the abilty to sort the commands alphabetically, add new ones and comment on existing commands. The site is a little barren at the moment and needs your input to make it work - but the interface is nice enough and easy to use. Check it out and see what you think. More details here: http://jessticular.dbspot.com/index.php?nav=dbhelp DBPro Sliding Collision CodeG Man and Lost in Thought from the forums have come up with a really nice piece of DBPro code that handles full-on sliding collision FPS style. There are plenty of comments in the source code so you can see what is going on and it handles collision against a variety of .X objects without too many issues. It doesn't handle jumping - but perhaps that is something you could add? More details here: http://forum.thegamecreators.com/?m=forum_view&t=45212&b=6 Katey's Quest - Final BetaWe reported on this Lode Runner inspired game several issues back and are pleased to announce that the game is now in the final beta stage. It's a seriously playable little title with great puzzles and level design. The graphics could do with a tweak here and there (perhaps forum member Calypson could offer a hand?!) but it doesn't detract from what is otherwise an excellent arcade title with a very retro feel. Katey has found herself trapped inside a magical world after falling into a mirror, the world being full of puzzles and monsters. Escape each level by collecting all the pieces of the mirror door and escape through it. We look forward to the final version very much! More details here: http://forum.thegamecreators.com/?m=forum_view&t=51317&b=8 onGamedev's First Spring Programming ContestFeel like getting involved in a spring programming contest? Then why not join in with the onGameDev "Shooter" contest? There are over $1000 worth of prizes up for grabs including copies of DarkBASIC Professional and FPS Creator. The genre for this contest is "Shooter." This can include a space shooter (Galaga-type), an FPS(Doom style), or any derivative thereof. Your submission must include the source code and the deadline is June 21st 2005. Read more here: http://www.ongamedev.com/contest.html Games to TestAnother month and another bunch of cool games that have caught our eye, each of them worth downloading and leaving comments in their forum threads. MoxBloxMox Blox 2005 is a puzzle-type game inspired by the classic Tetris. The main difference with Tetris is that you can play Mox Blox on a 3D board. The game offers several views, different 3D shapes, different game levels, two game types, dynamic cubes (bombs, freezes, etc.), side cameras, sound, lighting, and personalization of music. Download MoxBlox from: http://moxblox.free.fr. Write about MoxBlox: http://forum.thegamecreators.com/?m=forum_view&t=51178&b=5 WarpFlightWarpflight is a combination asteroid shooter and racer. The asteroids speed towards you, and you have to either shoot them or get out of the way. Pick up green power-ups to recharge your energy. your ship is under constant acceleration; it never slows down until the end of the level. Download WarpFlight from: http://files.thegamecreators.com/newsletter/WarpFlight.zip and visit the authors website: http://astrumgames.com Write about WarpFlight: http://forum.thegamecreators.com/?m=forum_view&t=52724&b=5 Crystal SeaCrystal sea is an arcade game based on the 1989 Micro User game by Rob Walmsley. Long ago a merchant ship laden with huge jars of diamonds from the east ran on to a reef. Water began to flood in and although the sailors began to throw their precious cargo overboard their plight became hopeless and the vessel sank leaving only one survivor to tell the tale. Ages passed and the story became a legend. But now the wreck has been found and you have come to recover perhaps the greatest sea treasure of all time. The water is very deep and you have to use a remote controlled droid to pick up each gem scattered across the sea floor, avoiding huge octopi intent on pulling your droid to pieces The machine needs two preset teleporters to jump up or down - any drop of more than one level causes its pressure hull to crack and it explodes. Download Crystal Sea from: http://www.darkdayssoftware.com/crystalsea/. Struck Gold!One day, while preparing the foundation...you stumble across a shiny object. With closer inspection, you realize that it isn't merely any object, but... "GOLD!!!!!" YOU FOUND GOLD!!!!! Without hesitation, you prepare your tools and begin to dig up the gold. The only problem is, that now the original owner wants the lot back, and has found a loop hole in the contract. However, if you can dig up enough gold by the dead line, you won't have to sell the property. Download Struck Gold from: http://files.thegamecreators.com/newsletter/Struck_Gold.zip. Write about Struck Gold: http://forum.thegamecreators.com/?m=forum_view&t=52755&b=8 Alley SquirrelYou are on a mission - a mission to find and capture the most dangerous criminal of the century. As an undercover agent you roam the alleys of Chicago searching for clues that will help you arrest and indite a vicious gangster who robs banks and sells the gold in a complex black market. Alley Squirrel includes three exciting levels each with an intense final challenge and at the end of the game, you must use the clues you've collected and all your wits to conquer the Ultimate Challenge. Download Alley Squirrel from: http://daudelin79.home.comcast.net/AlleySquirrel.zip. Got a quality game you'd like to see here? Then email us now! From the ForumsOur forums are a diverse and interesting place to hang-out and here are a selection of hot topics this month. A recent forum change includes the removal of the Team Requests board. The reason for this is that it was becoming a nightmare to control - some of the most insane requests for teams ever were being posted by people who'd have trouble writing Pacman, let alone a Halo beater. To this end it has closed its doors for good. Well formed team requests can be made in the DBPro, DB and WIP boards - in order for the moderators to not instantly lock and/or delete your request ensure you include the following: screen shots of the game so far (we will not accept requests for projects that havn't even started yet), link to a web site where people can perhaps download a test of the game or read further details. Be realistic about what you are asking for "we need 10 artists, 3 animators and 5 programmers" ISN'T realistic. Keep the request friendly, do NOT offer money or pretend the request is a real job or that you are a "real" company, it just sounds childish. Keep it open and easy. Here is a great example of a well planned team request - if yours doesn't match up to that, we WILL delete it. Here are a selection of forum threads this month that are worth looking over:
How to draw a Yak :)
DBPro Tutorial Videos
DreamCreator - RPG Maker
DBPro under Longhorn
GGRPG
Scratch the Dog You can find our forums at: http://forum.thegamecreators.com 20-Liner - Juggler by KelebrindaeThis is a fantastic 20-liner where you have to click on the ball to keep it in the air while trying to 'catch' good power-ups and avoid negative ones. If you hit the ground, you lose your high score. The realistic physics and challenge on one's reflexes make it a very enjoyable game, although the power-ups are a little spartan. Compare your high scores with others' in the thread! (Thanks to Ian for the review) The author of this 20-Liner has won any of the DBPro expansion packs, just email us to claim your prize. Download the 20-Line code from: http://forum.thegamecreators.com/?m=forum_view&t=51373&b=11 Transparent Water ShaderWhat happens if you take the Advanced Terrain demo created by TGC and throw in a rather gorgeous water shader and atmospheric sound effects? The result is this rather beautiful tech demo by BealziBob. Walk around the landscape and admire the water effect from various angles. Top-end graphics cards only for this beast though, don't even think about it unless you're running a very good graphics card (Radeon 9600/X800, GeForce FX/6800, etc) - both the source code and media are available for download. Source and EXE here: http://forum.thegamecreators.com/?m=forum_view&t=52376&b=1 Beginners DBPro Tutorial - Simple Landscapes by Michael ShahWelcome to yet another tutorial that'll teach you an important component for all your game creation needs. In this tutorial, I'm going to show you how to create a simple landscape, that'll get good performance on any system, and still look good.The full media and source can be downloaded, details at the end of the tutorial.
What will be covered `[====Functions====] `Functions are helpful because they allow us to keep doing something over and over `again wherever we put them. They can be thought of as custom commands, as you `can put whatever parameters you like in them to control how the command acts. ` `Example of a function: ` `function makecube(Objectnumber,size) ` make object cube Objectnumber,size `endfunction ` ` `You'll notice that whatever you put as a parameter(inside the parenthesis), you replace `with the values you'd normally put for any commands you use inside the function. ` `Functions do have their limits, like they can only return one value. If you're `working with lots of variables, be sure to consider if a function will benefit you. ` `Be sure to check out a more in-depth view of functions here: `//www.thegamecreators.com/data/newsletter/newsletter_issue_27.html#9 `[====Functions====] ` `[====Heightmaps====] `A heightmap is a 3D map/terrain generated from a 2D image. The height of the terrain is `based on the color of the pixels. Heightmaps are greyscale images, so you only need to `concern yourself with the values of 0-255 for each of the heights. Just remember, the `closer the pixel value is to white(255,255,255) the higher up the terrain will be. The `closer the pixel value is to black(0,0,0), the lower the terrain will be at that point. ` `In this tutorial, we'll load up an image, read each pixel, and set the height of the `matrix accordingly. `[====Heightmaps====] `Now that you know a little more about what we'll be doing, lets go ahead and get started. sync on : sync rate 60 `Set the refresh rate to 60 set display mode 1024,768,32 `Set the resolution of our program autocam off `Tell our camera not to be repositioned after creating an `object. mapsize =500 `This defines how big our terrain will be. segments= 64 `This is the number of segements we want in our matrix. make matrix 1,mapsize,mapsize,segments,segments `Here is our matrix, which will soon `be molded by our heightmap. load image "heightmap.bmp",1 `This is our heightmap image. size=256 `Since we know our heightmap is 256 by 256 pixels, we set `a variable for this. load image "texture.bmp",2 `This is our texture for the terrain prepare matrix texture 1,2,1,1 `This command applies the texture to the matrix. `This next step is the most important, as we'll begin reading our heightmap data. cls `Clear the screen, to make sure we can read the data correctly. paste image 1,0,0 `Paste the image to the screen. modifier=size/segments `Since our image has more pixels than we have segments, we need `to make sure we can account for that difference, by getting every `height after 2 pixels(256/128=2) rather than every pixel. for x = 0 to segments for y = 0 to segments pixelcolor#=rgbr(point(x*modifier,y*modifier)) `This will return the color value. set matrix height 1,x,y,pixelcolor# `With the color value, we then set the next x `matrix height according to that color. next y update matrix 1 `Finally, we must update our matrix to show the changes that've taken `place. ``````Creating the plants`````` load image "tree.bmp",3,1 `Here we load a uv map for our tree object. It's already `premade, so you don't need to worry about it. It'll rely `on transparency for the branches and detail(Go ahead and `take a look at the image). `This builds off the last tutorial, so be sure to not forget `that extra texture flag. load image "rose.bmp",4,1 `Here's our second plant, the flower(rose). Plants=940 `This variable defines how many plants we want total. There will `be an even amount of plants created(if plants is 800 then `400 trees and 400 flowers will be made). Be sure to make sure `the plants number is an even number, to keep things simple. for x = 1 to Plants/2 `This for-next statement uses our plant function to create some `plants. Please see bottom of source code for explanation as createplant(x,mapsize,1) `to how the function works. next x for x = (Plants/2)+1 to Plants createplant(x,mapsize,0) next x ```````Creating the water``````` `Many times people make creating water a huge task, and this can result in overkill in `both looks and system performance. For this tutorial, all we're going to do is make a `plain. Sounds a little too easy, but by placing it in the terrain, we'll let the terrain `create the smooth edges of the water for us. Also, by using an object for water `(versus a matrix), we can apply reflections or even(for more advanced users) shaders. `Lets keep things simple right now, and just get some decent looking water. water=5000 `Our variable for our water object make object plain water,mapsize,mapsize `We make it as big as our map, to ensure all areas `get covered. load image "water.bmp",water `Load our image we'll use to texture our water. texture object water,water `Texture our object set reflection shading on water `We give our object reflection properties. `Be careful, use this command sparingly, as it's `very system intensive. set alpha mapping on water,25 `We give our water transparency. `This way we'll be able to see through our water. waterheight=15 `This is where we'll position our water on the `y-axis. position object water,mapsize/2,waterheight,mapsize/2 `We position our water. xrotate object water,-90 `Rotate our water. `We don't want trees under our water, so we'll get rid of them. `If some trees are still half under the water, you can adjust the values accordingly. for x = 1 to Plants if object exist(x) `Check to see if the object exists if object position y(x)<=waterheight then delete object x `Delete object if it's under endif `the water. next x `As you'll see later in our main loop,(under "[====Water===]"), we'll make it slowly `move up and down to give it a coastline. `````Creating the skysphere````` `A skysphere is an object textured that'll act as the sky. Skysphere's are created `by using a sphere of a negative size(so the faces are flipped towards you) and then `texturing it. sky=5001 `Our variable for the skysphere. load image "sky.bmp",sky `Load our texture for the skysphere. make object sphere sky,(-mapsize*2) `Here we create our sphere, and ensure it's big enough `to cover the map, by multiplying it by the mapsize. texture object sky,sky `Texture our sky with the sky texture. position object sky,mapsize/2,0,mapsize/2 `We position our skysphere. `Note that we divide the mapsize by 2 because our object `has been rotated. :) `Later on, in the main loop, we'll rotate the skysphere. This will create the illusion that `the sky is actually moving like it really does. position camera 35,0,35 `Position the camera do `Initialize our loop text 0,0,str$(screen fps()) `Simple text statement that'll show the frames per second. text 0,30,str$(statistic(1)) `This text will show how many polygons are being rendered. `[====Camera movement====] `Here's our basic camera movement routine. `We use the 'control camera using arrowkeys command' to easily move our camera. `As well as doing that, we create a variable called 'cy#' to get the terrain height. `Based on the terrain height and camera position, the camera will position itself `accordingly on the y-axis. y#=get ground height(1,camera position x(),camera position z()) control camera using arrowkeys 0,1,1 position camera camera position x(),y#+5,camera position z() `Position the camera `[====Water===] `To move the water up and down, we have one variable that controls the direction of the `water. Based on the waters height, that variable will change. if down=0 `The water moves up when down=0. move object water,.005 `Since we rotated the object, we use the move command to `move the water up. if object position y(water)>=waterheight then down=1 `If the water gets to high, down=1 endif if down=1 `The water moves down when down=1 move object water,-.005 `Since we rotated the object, we use the move command to `move the water down if object position y(water)<=waterheight-1 then down=0 `If the water gets to low, down=0. endif `Just to get a little fancy, we'll color the ambient light a different color when we're `below it. This will help make us feel like we're more under water. if camera position y() |
|||||||||||||||||