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

_Zac_

Members
  • Content count

    17
  • Joined

  • Last visited

Community Reputation

138 Neutral

About _Zac_

  • Rank
    Member
  1. Alright, I know Frame Limiting is something that's brought up a lot, but my question is how do I do it accurately. I've noticed that my display surface somehow never gets double-buffered, so I'm trying to find another way. Considering that 1000/60 is a decimal while SDL_GetTicks() is an integer, it's extremely hard to get an accurate 60 FPS. So far I've tried waiting for 16ms one frame, then 17ms the next two and just repeating this cycle (updating the average every 3 frames of course). (16+17+17)/3=16.666... but my FPS calculator keeps detecting 60.049 FPS this way. I've also tried creating a float and after waiting the desired amount of milliseconds doing while((Uint32)NextTick<=SDL_GetTicks())NextTick+=1000.0f/60.0f; Usually with the same results but with a less stable framerate. So either my FPS counter is wrong and I'm getting 60 FPS (sometimes dipping) or I can't really get more accurate than 60.049 FPS +or-0.1 What would be the most accurate way to achieve 60 FPS without double buffering?
  2. I guess a few things to start off with, I'm using C++. Alright, I have this class called ObjectHandler, which pretty much handles all the game objects. A game Object is defined as anything with a loop() and render() function as well as collision functions. The ObjectHandler stores all the Objects in a vector that when you call the ObjectHandler's loop() or render() functions it then calls every Objects loop() or render() functions. Now, when calling the loop command the ObjectHandler gives itself to the object (like calling Object.loop(ObjectHandler this) so that the Object can use the ObjectHandler to check collisions with all other objects. The problem here is that if I call the ObjectHandler for a collision check I cannot check for specific subclasses of Object without creating separate functions and separate vectors. So for a gist here's some psuedocode for what I want to do: [code] bool ObjectHandler::collision(class x) { for(int i=0;i<ObjVect.size;i++) { if(ObjVect[i] could be considered an x && ObjVect[i]->collision()) { return true; } } return false; } [/code] Now of course collision would have a few more variables to pass in, but I believe this gets the point across of what I want to do. Now I hear there is an easy way of doing this in C#, but I also hear that if you ever have to call a function to tell if a certain object is a certain class then you have design flaws. So I'm wondering if doing it like this is a major flaw in design and would be greatful if you could point me towards some faqs or give some advice if you believe that is the case.
  3. Like what KDMiller3 said, you should create a function that will tell you if there is nothing taking space in the location you want to move to. So like if(areaAvailabe(<where player wants to move>)) returns true then proceed to move the player there. Though it's mostly the reverse of what you're doing now.
  4. If I put in a rectangle that has x and y equal 0, and the width and height equal to 32, and then blit it, would it draw a rectangle from 0 to 31 x and y? (So top-left corner is at (0,0) and the bottom-right corner is at (31,31)) Thanks, I need to know this because I created a collision-detection function that takes in a rectangle's x,y,width and height and that one pixel could make all the difference.
  5. Alright, just checked again, and it actually does not work. Must of grown delirious when programming late at night and assumed it was fixed. Anyway, File.c_str() doesn't work, but just putting in "./image.png" does, even though File.c_str() should equal the same thing. Since SDL stops you from outputting to the console I'm going to work on writing the strings to files like Ectara said. OnLoad() (which is a part of CSurface) is declared as a static function. You put in a char array (or c-string as I think they're called) and then it returns a pointer to a surface. What's odd is that it seems to still return a not null value when it fails to load the surface. EDIT: Ok, it's working again. I just made a stupid error that gave me some weird results. I'm pretty strung out right now though, so I'll work on what I want for awhile before I post another question here. Thanks again everyone.
  6. I edited the OP stating that I fixed it by using File.assign() instead of File=. Though I guess if you want to clarify: std::string File function(std::string n){File=n;} The function is then called likeso: function("name"); Why would File=n not work yet File.assign(n) does?
  7. Because I don't like switching through .h and .cpp files, I just put the headers and the code in the .h file. How bad of a practice is this? For example [code] class a { private: function(); }; a::function() { } [/code]
  8. Alright, I'm having another problem. File is a std::string equal to "./image.png" I use a function that takes a filename as a const char* and loads an image. OnLoad(File.c_str()) fails to load the file OnLoad("./image.png") works. How do I convert File into a const char* that would work with this? (No I cannot change the function to take in a std::string instead) Tell me if you need more information, I'm updating the OP to include code I believe is relevant.
  9. Thank you so much guys. I really should've know that about strcpy. I'm switching to std::string's and just to have an easier time with this.
  10. [code] #ifndef _GAME_H_ #define _GAME_H_ #include "State.h" #include "CEvent.h" #include "GSurface.h" #include <iostream> class Game:public CEvent { private: bool Running; SDL_Surface* SurfDisplay; State* CurrentState; GSurface* temp; SDL_Surface* temp2; public: Game(); ~Game(); int onExecute(); bool onInit(); //inits display surface void onEvent(SDL_Event* event); //Handles button presses void onLoop(); //Game Loop void onRender(); //Graphics void onCleanup(); //Cleans up entire game void onExit(); //Sets Running to false void OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode); }; Game::Game() { SDL_Init(SDL_INIT_EVERYTHING); Running=true; SurfDisplay=0; CurrentState=0; temp=0; //temp=new GSurface("image0","./image.png"); temp2=0; } bool Game::onInit() { //if(SDL_Init(SDL_INIT_EVERYTHING)<0){return false;} SurfDisplay=SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF); if(SurfDisplay==NULL) { return false; } temp=new GSurface("image0","./image.png"); temp2=CSurface::OnLoad("./image.png"); return true; } void Game::onRender() { if(temp->drawSurface(SurfDisplay,32,32)==false) { Running=false; } //CSurface::OnDraw(SurfDisplay,temp2,0,0); SDL_Flip(SurfDisplay); } [/code] The previous problem I was having has been fixed, but now I have a new problem, though it still concerns strings. The function OnLoad() takes in a const* char and returns a pointer to an SDL_Surface. The variable File is a std::string equal to "./image.png". I put in File.c_str() but it fails to load. When I put in "./image.png" instead it works. I wish to know what I am doing wrong and what I can do to solve this. [code] #ifndef _GSURFACE_H_ #define _GSURFACE_H_ #include "CSurface.h" #include <iostream> class GSurface { public: std::string File; private: SDL_Surface* Surface; std::string Name; //std::string File; bool Loaded; Uint8 R,G,B,A; int Width,Height; int iWidth,iHeight; int ImageMax; public: GSurface(std::string n,std::string location); GSurface(std::string n,std::string location,int iw,int ih); GSurface(std::string n,std::string location,int iw,int ih,Uint8 red,Uint8 green,Uint8 blue,Uint8 alpha); //GSurface(char* n,char* location,Uint32 RGBA); ~GSurface(); bool drawSurface(SDL_Surface* surfDest,int x,int y,int ix,int iy,int w,int h); bool drawSurface(SDL_Surface* surfDest,int x,int y,int image); bool drawSurface(SDL_Surface* surfDest,int x,int y); bool setAlpha(Uint8 a); //Sets alpha of surface void setColorKey(Uint8 r,Uint8 g,Uint8 b,Uint8 a); //Sets color key and alpha void setImage(int w,int h); //bool setColorKey(Uint32 rgba); std::string getName(); void setName(std::string n); void free(); //calls unload() private: bool load(); void unload(); void checkLoaded(); }; GSurface::GSurface(std::string n,std::string location) { GSurface(n,location,NULL,NULL,NULL,NULL,NULL,NULL); } GSurface::GSurface(std::string n,std::string location,int iw,int ih) { GSurface(n,location,iw,ih,NULL,NULL,NULL,NULL); } GSurface::GSurface(std::string n,std::string location,int iw,int ih,Uint8 red,Uint8 green,Uint8 blue,Uint8 alpha) { Name=n; File=location; R=red; G=green; B=blue; A=alpha; iWidth=iw; iHeight=ih; Surface=NULL; Loaded=false; Width=Height=ImageMax=0; } GSurface::~GSurface() { unload(); Surface=NULL; } bool GSurface::load() { if(Loaded==true) { return true; } //Surface=CSurface::OnLoad(File.c_str()); NOTE: Does Not Work Surface=CSurface::OnLoad("./image.png"); //But if replaced with this it does work if(Surface==NULL) { return false; } Loaded=true; if(Width==0) { Width=Surface->w; Height=Surface->h; } if(R!=NULL&&G!=NULL&&B!=NULL&&A!=NULL) { CSurface::OnColorKey(Surface,R,G,B); } return true; } void GSurface::unload() { SDL_FreeSurface(Surface); Surface=NULL; } bool GSurface::drawSurface(SDL_Surface* surfDest,int x,int y) { checkLoaded();if(!Loaded){return false;} return CSurface::OnDraw(surfDest,Surface,x,y); } bool GSurface::drawSurface(SDL_Surface* surfDest,int x,int y,int ix,int iy,int w,int h) { checkLoaded();if(!Loaded){return false;} return CSurface::OnDraw(surfDest,Surface,x,y,ix,iy,w,h); } bool GSurface::drawSurface(SDL_Surface* surfDest,int x,int y,int image) { checkLoaded();if(!Loaded){return false;} int ix,iy,fw; while(image>ImageMax) { image-=ImageMax; } fw=(int)(Width/iWidth); ix=(image%fw)*iWidth; iy=(image/fw)*iHeight; return CSurface::OnDraw(surfDest,Surface,x,y,ix,iy,iWidth,iHeight); } void GSurface::setColorKey(Uint8 r,Uint8 g,Uint8 b,Uint8 a) { R=r; G=g; B=b; A=a; if(Loaded==true) { CSurface::OnColorKey(Surface,R,G,B); } } void GSurface::setImage(int w,int h) { iWidth=w; iHeight=h; } void GSurface::checkLoaded() { if(!Loaded&&load()) { Loaded=true; } } std::string GSurface::getName() { return Name; } void GSurface::setName(std::string n) { Name=n; } void GSurface::free() { unload(); } #endif [/code] [code] SDL_Surface* CSurface::OnLoad(const char* File) { SDL_Surface* Surf_Temp=NULL; SDL_Surface* Surf_Return=NULL; if((Surf_Temp=IMG_Load(File))==NULL) { return NULL; } Surf_Return=SDL_DisplayFormat(Surf_Temp); SDL_FreeSurface(Surf_Temp); return Surf_Return; } [/code]
  11. I'm guessing you've already included 'mingw32', 'sdlmain' and 'sdl', but just in case, check that. Else, right-click the project>Build Options...>Linker Settings and add them. But considering it actually worked before this may not be the case.
  12. When most games are released you'll usually never find the resources (images, sounds, etc.) just out in the open when searching through the folders. When I looked at a Doujin game I downloaded they were all in a .dat file that was next to the original .exe. There was no easy way for me to extract the information from these files. I was wondering how I could implement this. Are they like folder files or zip files? (I really don't know more about this topic other than "all the resources are packed into these .dat files and I want to know how to do the same".)
  13. I remember a scene in FFX (or was it X-2?) where you pretty much fight the Yevon army...and win. It's pretty much the game saying "These few people can destroy an army, so why not Sin?" Most JRPGs (and probably WRPGs, but I haven't played much of those) like to just suspend your disbelief to the point where you believe you're more powerful than an army. And even then, most games have you kill a ton of enemy NPCs (those random encounters) so you've already been killing "armies" of critters. So really what causes you to not stop and think about that is because the game has been repeatedly telling you through random encounters and such that your party is capable of killing tons of people, probably without even breaking a sweat.
  14. It's true that most ideas are bad ideas. You just have to filter them out and work with what you think is good. I've heard from someone that makes EDM as a hobby that he works on around 20 projects at a time, and I'm sure many musicians do the same, and then they cherry-pick the actual good ones to release to the public. The songs you hear from a good band are actually the tip of an iceberg where-in under the water is just a bunch of so-so to downright terrible ideas they've had over time. Brainstorm and expand on your ideas, and find one you feel you'll actually want to work with. It's not an easy process.
  15. You just made me realize how inefficient my engine is. I use two collision checks every step, once after calculating the player's X movement and once after calculating the player's Y movement. But it works perfectly. For example: In the X check, if the player moved right and is now colliding with a block, it must of collided with it on its left side. So the player moves to the block's left edge. In the Y check, if the player fell and is colliding with a block, then it must of collided on its top surface, so the player is moved accordingly. You could try that if it doesn't reduce the framerate. Though I'm sure there's a more efficient way of doing it.