• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

131 Neutral

About PhantomRonin

  • Rank
  1. So I am currently making a game and I want to have online multiplayer 1v1. I have never done any type of networking before and I was wondering if anyone could point me in the direction of good tutorials. I have looked and am having a hard time finding anything. I am using C++ and SFML.
  2. This is what my main looks like [source lang="cpp"]int main() { sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), WINDOW_TITLE); window.setTitle(WINDOW_TITLE); GraphicsManager graphicsManager; graphicsManager.loadTextures(); Player player; player.setSprite( graphicsManager.getSprite(1) ); player.setWeaponSprite( graphicsManager.getSprite(3) ); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } player.getInput(); window.clear(); window.draw(player.getSprite()); window.display(); } return 0; }[/source]
  3. [quote name='Servant of the Lord' timestamp='1355634729' post='5011175'] As JTippets mentioned, just give each object its own sprite. You could share textures between similar types of objects, but you don't need to do all the hassle of a "graphics manager", especially when that "manager" doesn't actually manage the lifetime of your graphics. But hey, if every Enemy has the same appearance, you could even share their texture statically: [code]class Enemy { public: static bool LoadResources(); //Loads all the static textures. Called once at program startup. enum class Appearance {Normal, Fast, Powerful, Dead}; public: Enemy(); void SetAppearance(Appearance appearance) { if(appearance == Appearance::Fast) { this->sprite.setTexture(Enemy::fastTexture); } else if(appearance == Appearance::Powerful) { this->sprite.setTexture(Enemy::powerfulTexture); } else if(appearance == Appearance::Dead) { this->sprite.setTexture(Enemy::deadTexture); } else //Normal appearance. { //Randomly choose one of the two 'normal' enemy textures. if( random choice 1 ) { this->sprite.setTexture(Enemy::normalTexture1); } else { this->sprite.setTexture(Enemy::normalTexture2); } } } private: sf::Sprite sprite; //Each enemy has it's own sprite. static sf::Texture normalTexture1; //Normal enemy texture, shared between all 'Enemy' instances. static sf::Texture normalTexture2; //An alternative texture for normal enemies. static sf::Texture fastTexture; //Texture for 'fast' enemies. static sf::Texture powerfulTexture; //Texture for 'powerful' enemies. static sf::Texture deadTexture; //Texture for dead enemies. };[/code] [/quote] Each object does have its own sprite. I load up all the textures in the graphics class. Then I create a sprite and send it over to another class. I only do this once per class. Anyway thanks for the advice everyone
  4. [quote name='Servant of the Lord' timestamp='1355630922' post='5011163'] As a general rule of thumb, I pass structs and classes by const reference or non-const references, and only copy something when I actually want a duplicate. Basic variables like int and float I pass by value, normally. Could you show a real piece of code as an example, to clarify your question? [/quote] Basically how I have it set up right now I have Player class, Enemy class, and Graphics class. The graphics calls loads all the textures. Then I send over the sprite using the function below to the class that needs it. [source lang="cpp"]sf::Sprite GraphicsManager::getSprite(int textureID) { sf::Sprite sprite; switch(textureID) { case 1: sprite.setTexture(player); return sprite; case 2: sprite.setTexture(enemie); return sprite; case 3: sprite.setTexture(ball); return sprite; } } [/source] Thinking about it now would it be better to keep everything in the graphics class and do something like this when drawing? [source lang="java"]window.draw( graphics.getsprite(player.x,player.y,player_spriteID);[/source]
  5. [quote name='Cornstalks' timestamp='1355628973' post='5011153'] Depends on what you want. It's safe to not use pointers, but you have to realize that the two classes will each have their own copy of the [font=courier new,courier,monospace]sf::Sprite[/font] if you don't use references/pointers. If you want them to share the same [font=courier new,courier,monospace]sf::Sprite[/font], you have to use references/pointers. [/quote] Im talking about from an efficacy point of view. Will my code run slowly if I am sending a hand full of sprites around at start up?
  6. If I am sending sf::Sprite objects between classes should I be using pointers?
  7. [quote name='JTippetts' timestamp='1353386946' post='5002580'] The thing about Perlin noise is that at frequency=1, there is roughly 1 feature per unit. At frequency=3, in your case, you have roughly 3 features per unit. However, you are sampling an area 64x48 units in size, so you will end up with a mapping containing roughly 192x144 features, which is going to look a whole lot like white noise. You should try disconnecting your pixel size from the actual size of the area of noise that you map, if you want to get anything useful. [/quote] Thanks I think I figured it out
  8. I would also like to mention in case it was to clear it does compile and run the output is the problem
  9. So I want to make a game with a procedural generated map using Perlin noise but im having issues. I have read up on Perlin Noise so I know what is going on behind the scenes but when I try to implement it it just looks like incoherent garbage. So I am using the code from this link [url="http://stackoverflow.com/questions/4753055/perlin-noise-generation-for-terrain"]http://stackoverflow...ion-for-terrain[/url] . I dont know if the code I am using is funky or if I have implemented it wrong. I have tried to use code from another site and that failed also. [source lang="cpp"]#pragma once class PerlinNoise { public: // Constructor PerlinNoise(); PerlinNoise(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed); // Get Height double GetHeight(double x, double y) const; // Get double Persistence() const { return persistence; } double Frequency() const { return frequency; } double Amplitude() const { return amplitude; } int Octaves() const { return octaves; } int RandomSeed() const { return randomseed; } // Set void Set(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed); void SetPersistence(double _persistence) { persistence = _persistence; } void SetFrequency( double _frequency) { frequency = _frequency; } void SetAmplitude( double _amplitude) { amplitude = _amplitude; } void SetOctaves( int _octaves) { octaves = _octaves; } void SetRandomSeed( int _randomseed) { randomseed = _randomseed; } private: double Total(double i, double j) const; double GetValue(double x, double y) const; double Interpolate(double x, double y, double a) const; double Noise(int x, int y) const; double persistence, frequency, amplitude; int octaves, randomseed; };[/source] [source lang="cpp"]#include "PerlinNoise.h" PerlinNoise::PerlinNoise() { persistence = 0; frequency = 0; amplitude = 0; octaves = 0; randomseed = 0; } PerlinNoise::PerlinNoise(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed) { persistence = _persistence; frequency = _frequency; amplitude = _amplitude; octaves = _octaves; randomseed = 2 + _randomseed * _randomseed; } void PerlinNoise::Set(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed) { persistence = _persistence; frequency = _frequency; amplitude = _amplitude; octaves = _octaves; randomseed = 2 + _randomseed * _randomseed; } double PerlinNoise::GetHeight(double x, double y) const { return amplitude * Total(x, y); } double PerlinNoise::Total(double i, double j) const { //properties of one octave (changing each loop) double t = 0.0f; double _amplitude = 1; double freq = frequency; for(int k = 0; k < octaves; k++) { t += GetValue(j * freq + randomseed, i * freq + randomseed) * _amplitude; _amplitude *= persistence; freq *= 2; } return t; } double PerlinNoise::GetValue(double x, double y) const { int Xint = (int)x; int Yint = (int)y; double Xfrac = x - Xint; double Yfrac = y - Yint; //noise values double n01 = Noise(Xint-1, Yint-1); double n02 = Noise(Xint+1, Yint-1); double n03 = Noise(Xint-1, Yint+1); double n04 = Noise(Xint+1, Yint+1); double n05 = Noise(Xint-1, Yint); double n06 = Noise(Xint+1, Yint); double n07 = Noise(Xint, Yint-1); double n08 = Noise(Xint, Yint+1); double n09 = Noise(Xint, Yint); double n12 = Noise(Xint+2, Yint-1); double n14 = Noise(Xint+2, Yint+1); double n16 = Noise(Xint+2, Yint); double n23 = Noise(Xint-1, Yint+2); double n24 = Noise(Xint+1, Yint+2); double n28 = Noise(Xint, Yint+2); double n34 = Noise(Xint+2, Yint+2); //find the noise values of the four corners double x0y0 = 0.0625*(n01+n02+n03+n04) + 0.125*(n05+n06+n07+n08) + 0.25*(n09); double x1y0 = 0.0625*(n07+n12+n08+n14) + 0.125*(n09+n16+n02+n04) + 0.25*(n06); double x0y1 = 0.0625*(n05+n06+n23+n24) + 0.125*(n03+n04+n09+n28) + 0.25*(n08); double x1y1 = 0.0625*(n09+n16+n28+n34) + 0.125*(n08+n14+n06+n24) + 0.25*(n04); //interpolate between those values according to the x and y fractions double v1 = Interpolate(x0y0, x1y0, Xfrac); //interpolate in x direction (y) double v2 = Interpolate(x0y1, x1y1, Xfrac); //interpolate in x direction (y+1) double fin = Interpolate(v1, v2, Yfrac); //interpolate in y direction return fin; } double PerlinNoise::Interpolate(double x, double y, double a) const { double negA = 1.0 - a; double negASqr = negA * negA; double fac1 = 3.0 * (negASqr) - 2.0 * (negASqr * negA); double aSqr = a * a; double fac2 = 3.0 * aSqr - 2.0 * (aSqr * a); return x * fac1 + y * fac2; //add the weighted factors } double PerlinNoise::Noise(int x, int y) const { int n = x + y * 57; n = (n << 13) ^ n; int t = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff; return 1.0 - double(t) * 0.931322574615478515625e-9;/// 1073741824.0); }[/source] Those files I borrowed and this is my implementation. This is not my exact code but its the important stuff [source lang="cpp"]float persistence = 1; float frequency = 3; float amplitude = 64; int octaves = 6; int seed = SDL_GetTicks(); PerlinNoise NoiseGenerator(persistence,frequency,amplitude,octaves,seed); for(int x = 0; x < 64; x++) for(int y = 0; y < 48; y++) { //I add 128 becuase I should get a range from roughly //-128 to 128 so adding 128 gives me the full range of color int a = (int)(NoiseGenerator.GetHeight(x,y) + 128); SDL_FillRect(screen,&rect, SDL_MapRGB( fmt, a, a, a)); } [/source]
  10. [quote name='DZee' timestamp='1342745033' post='4961115'] I think it could be relatively simple. If the camera follows your character in a fixed center point you could overlay the rendering with an image that has a transparent center point which fades into black around the edges. You could even make this a sprite and animate it slightly for a closer feel of having a torch lighting the zone. Then I suppose you could calculate the distance of your character and other objects to provide the illusion that they are essentially appearing within the viewport area. [/quote] Yea I was thinking of doing this but if I wanted more then one torch I would have trouble
  11. So I want to make a game that uses light. I want the player to be able to be in a dark room and carry a light so the area around him lights up. I am not exactly sure how to go about doing this so if someone could explain the best way to go about doing this or point me in the direction of a tutorial that would be nice.
  12. Ok another question when I go fullscreen how do I deal with the sprites? Do I have to have different sprites for different resolutions or can I resize somehow with SDL?
  13. [quote name='rip-off' timestamp='1337849603' post='4942840'] If the monitor does not support the requested resolution, SDL tries to emulate it. To avoid this, try to pick a resolution is directly supported. You can list them using SDL_ListModes: [url="http://sdl.beuc.net/sdl.wiki/SDL_ListModes"]http://sdl.beuc.net/...i/SDL_ListModes[/url]. [/quote] Thanks that should help
  14. When I create a window and make it fullscreen in SDL it doesnt go completely fullscreen. It leaves me with black bars on the side. Anyone know why this could be?
  15. So I started programming my game the other week. I got some basic player movement stuff down and some of the under the hood engine stuff working. I then decided to move onto the art which is when I remembered I am absolutely awful at art and the time I would spend on god awful pixel art would not be worth it. So how could I find someone willing to do art for cheap and how much would it cost? I am willing to pay somone but I have limited resources. Also I am not talking about AAA level art just some decent art so the game doesnt look like complete crap