• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

ProgrammerGuy123

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

127 Neutral

About ProgrammerGuy123

  • Rank
    Member
  1. I need help on how I should go about updating entities in my game with a chunk based approach. It's a 2D tile based side scroller. This is about updating the entity logic not drawing tiles.   My game is going to have different entities like monsters and projectiles. I don't wan't to update all the hundreds of entities in the map at the same time so I need some sort of chunk system, where I split the map up into chunks and only update the chunks that are visible.   With this in mind I thought about giving each chunk a list of entities that belong to it. Then I could update each visible chunk, which would cycle through the chunk's list and update each individual entity. If an entity like a monster moves from one chunk to another I could remove it from the previous chunk's list and add it two the new chunk's list.   However, say I shoot a projectile off my screen, then the entity would not get updated until the chunk is able to update which means making that chunk visible. I guess I would just have to force update the chunks the projectile is in then.   It seems like that could work, but there are probably more efficient ways to handle cutting down hundreds of entity updates to tens of entity updates, which is why I'm asking. This is a very fundamental concept to any large tile based game, so I want to here what your method is. How do you handle updating entities in a efficient matter?   Thanks.
  2. Objects in my game have both update and draw functions as expected, the update function sometimes need a delta time variable and the draw function sometimes needs a window object.   I have seen lots of engines pass in the delta time variable through every update function and pass in the window object through every draw function like so: //C++ void State::update(float deltaTime) {      sprite.pos += vel * deltaTime; } void State::draw(Window window) {      window.draw(sprite); } The problem with passing these objects through every single update and draw method is that sometimes the're not used. For example, a main menu does not need a delta time variable but does need a window object, but you can't just omit the parameter if you don't need it because the main menu inherits from the game state object which contains the parameters.   So would it be better in design to never pass these objects into functions but instead make them static like so? //C++ void State::update() {      sprite.pos += vel * GameManager::deltaTime; } void State::draw() {      GameManager::window.draw(sprite); } I'm asking because this is a very fundamental concept to game engines and the latter example just seems to make more since but it seems like the former example is favored.   Which is better code design? Thanks.
  3. Ah yes thank you. Very informative links.
  4. I'm trying to implement hovercraft like physics into my game but I need help. An improtant thing to note is that the hovercraft will be pretty high off the ground unlike realistic hovercrafts. After searching and asking questions I arrived at this source code: [CODE] double g = 9.8d; //gravity double m = 1.0d; //mass double fMax = 15; //maximum upwards force double idealHeight = 100; //ideal height the craft should be off the ground double v; //velocity void Update() { double h = Math.Abs((craft.Y + craft.Height) - ground.Y); //determin the craft's height from the ground. double a = (g - f(h)) * m; //acceleration v += a; //velocity v = MathHelper.Clamp((float)v, -15.0f, 15.0f); //make sure the acceleration doesn't get out of hand craft.Y += (int)v; //assign the velocity } double f(double h) { //this function return the amount of upwards force return Math.Max(0, h * (g - fMax) / idealHeight + fMax); } [/CODE] One cunfusing thing to note is that my game is 2D with (0, 0) being the top left corner of the window and (100, 100) being accrosed and down 100 pixels. This is why I have the Math.Abs(craft.Y + craft.Height) - ground.Y whole thing. Now the problem: This code works but the craft just goes up and down up and down up and down enlessly. I would like the craft's velocity to diminish over time to equal out with the idealHeight. Like [url="http://i.imgur.com/merx8.png"]this[/url] picture shows. How would I do that? Thanks.
  5. Thank you and everyone else I just need the /100 and it works perfectly now!
  6. That is indeed how I'm called the method: [CODE] byte[,] temp = new byte[height, width]; for(int x = 0; x < width; x++) { byte value = (byte)((PerlinNoise2D((double)x) * 64) + 64); temp[value, x] = 1; } [/CODE] This is exactly why I was using integers in my pervious attempts for everything and not decimals. Is there any way I could efficiently convert the integers into decimals and back into inegers again? Or should I go back to the way I was doing it and have everything calculated with integers. Right now I'm multiplying the perlin value by 64 just for testing as you can see then adding the same value to get rid of any negatives. But like you said I'm only going to get values based on integer boundries so what should I do?
  7. [quote name='FLeBlanc' timestamp='1338478848' post='4945015'] You have revised it to be even more wrong than before. By just calling Next without the seeding operation, you guarantee you get a different value for any given input point each time it is called. Random isn't really what you want to use here. You want a hash function, that correlates an input, x, to an output, y. The hash needs to ensure that the hash for x+1 is in no way correlated to the hash for x, so that patterns do not appear in the output. jtippets linked to the reference implementation for Perlin noise. It might be a good idea to look and see how it does hashing, interpolation, etc... Also I note that you seem to be using a lot of integer coordinates and values. There is a problem with this. The algorithm you are using will generate pseudo-random values at integer coordinates, but since you never sample the "between" points (non-integer), the result is probably going to look a great deal like white noise. [/quote] Ok so I tried to fix a lot all of these problems but the function is still acting up and I'm really confused on why because I scrapped the whole thing to use double values instead of integers and I even took the complete RNG from [url="http://freespace.virgin.net/hugo.elias/models/m_perlin.htm"]this[/url] article about perlin noise. This solves the problem of having to use hash tables because now I'll get a random number where x and x+1 is a completely different number. However now it seems to return negative values which makes absolutely no since considering I use his RNG not .NET's. Also the InterpolatedNoise method is almost the exact same I'm just not smoothing the values because I want to simplify it. Then there is the CosineInterpolate method. To me logically this must be the reason for my negative values because as stated before I took the entire RNG from the article so it can't be that. The CosineInterpolate method was taken from [url="http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/"]this[/url] article. I've made no methods all the methods responsible for generating perlin values are from reliable sources. What is going on? [CODE] public double PerlinNoise2D(double x) { int octaves = 1; double freq = 16; double amp = 1; double total = 0; for(int i = 0; i < octaves; i++) { total += InterpolateNoise(x * freq) * amp; } return total; } double InterpolateNoise(double x) { int xInt = (int)x; double xFrac = x - xInt; double v1 = Noise(xInt); double v2 = Noise(xInt + 1); return CosineInterpolate(v1, v2, xFrac); } double Noise(int x) { x = (x<<13) ^ x; return ( 1.0 - ((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); } double CosineInterpolate(double a, double b, double x) { double f = (1 - Math.Cos(x * Math.PI)) / 2; return (a * (1 - f) + b * f); } [/CODE]
  8. [quote name='jefferytitan' timestamp='1338441167' post='4944882'] If I recall correctly, each time around the main loop you're meant to double the frequency and decrease the amplitude. You seem to be keeping them constant. [/quote] The values were not changing because I only had one octave for simplicity therefor there was no need for them to change. [quote name='Olof Hedman' timestamp='1338448657' post='4944897'] You are also using Random() wrong. You should initialize it once, with a single seed of your choosing, and then just continuously call "next" to read out the random value. [/quote] This was a mistake on my part I was thinking I needed a random value based on "x" which mean if "x" is ever the same it should generate the same number. I have revised the code I think to fix this problem but no luck. First I need just one octaves to work then I can generate more and add them up but for now I'm focusing on one octave which you will see in my code: [CODE] public int PerlinNoise2D(int x) { int total = 0; int octaves = 1; //only one octave for simplicity for(int i = 0; i < octaves; i++) { int freq = 16;//16 for simplicity I only have one octave so it doesn't need to change int amp = 1; //1 for simplicity again ^^^ total += InterpolateNoise(x * freq) * amp; } return total / octaves; } int InterpolateNoise(int x) { int v1 = random.Next(64); int v2 = random.Next(64); return CosineInterpolate(v1, v2, x, 16); // the 16 is from the frequency } int CosineInterpolate(int a, int b, int x, int length) { return (int)((1 + Math.Cos(3.1415f * x / length)) / 2 * (a - b) + b); } [/CODE]
  9. I understand the concept behind perlin noise but I can't understand why the method doesn't return perlin values: [CODE] public int PerlinNoise2D(int x) { int freq = 4;//initFrequency; int amp = 1;//initAmplitude; int total = 0; for(int i = 0; i < octaves; i++) { total += InterpolateNoise(x * freq) * amp; } return total; } int InterpolateNoise(int x) { int v1 = new Random(x).Next(64);//this returns a pseudo-random number less than 64 with "x" as the seed int v2 = new Random(x + 1).Next(64); return CosineInterpolate(v1, v2, x, 4); } int CosineInterpolate(int a, int b, int x, int length) { return (int)((1 + Math.Cos(3.1415f * x / length)) / 2 * (a - b) + b); }[/CODE] It generates repeating values that are not perlin and as explained before I need help on fixing it. Thanks.
  10. [quote name='JTippetts' timestamp='1336344285' post='4937893'] You interpolate the top-left and top-right corner values based on the x coordinate, interpolate the bottom-left and bottom-right corners based on the x coordinate, then interpolate these two intermediate values based on the y coordinate. [/quote] What do you mean by "corner values"? The octaves are made up of multiple squares. Am I getting the corner values of those squares? Wouldnt they be the same value then? Could you explain what you mean by this?
  11. I'm trying to create perlin noise but I'm having trouble understanding how interpolation works. I understand how to do it in a single dimension but can't wrap my head around it in two. Right now I have this for an octave: [img]http://i.imgur.com/XDuly.png[/img] Obviously this is not coherent and I need to interpolate to get something similar to this: [img]http://i.imgur.com/sgwcJ.png[/img] Most sources such as [url="http://freespace.virgin.net/hugo.elias/models/m_perlin.htm"]this[/url] explain how to do it one dimension but don't in two. Quote: "You can, of course, do the same in 2 dimensions." So could someone explain the concept of how [u]linear[/u] interpolation works in two dimensions? Thanks.