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

Martin Barbov

  • Content count

  • Joined

  • Last visited

Community Reputation

137 Neutral

About Martin Barbov

  • Rank
  1. Yeah, typing mistake :p Thanks a lot guys, I made the coordinates into floats and the movement is much smoother now,   Final question, is it normal that the SDL fullscreen is not stretching onto the entire screen but only to its dimensions even if I set them to some known resolution like 1024 x 768 and so on. It works fine only if the resolution matches the monitor resolution but if smaller, it will be centered and surounded by black border. Is there a fix that doesn't require manual stretching of the screen?
  2. @Khatharr  Thank you very much for the input. It seems I'll have to rewrite the motion mechanic and do some time system I currently lack.   @rip-off I wasn't aware    Thought it was angles. It's ok now   As for the freezing it was just like game lag.The game screen freezes, slowing down the whole system, but not crashing windows or something. The loop polls for events. I just commented that part for testing purposes. I did some testing and now it's much better. After I put a SDL_delay(8) in the loop. 
  3. Here's the relevant code:       This updates the screen.  void UpdateScreen() { SDL_Surface* frame = SDL_GetVideoSurface(); int i = SDL_Flip(frame); }   This blits a surface to another surface void Asset::apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { //Temporary rectangle to hold the offsets SDL_Rect offset; //Get the offsets offset.x = x; offset.y = y; //Blit the surface SDL_BlitSurface( source, NULL, destination, &offset ); }   This just calls the previous function but uses fewer parameters and is callable from outside the class. image is a SDL_surface* loaded with an image. void Asset::apply(int x, int y, SDL_Surface* dscreen) { //Apply the background to the screen apply_surface( x, y, image, dscreen ); }     This uses the previous function to draw the object. assetx and assety are there if I want to displace the image from the actual game object. They are 0 by default. void Object::Render() { SDL_Surface* screen = SDL_GetVideoSurface(); if(render&&exist) asset->apply(x+assetx,y+assety,screen); }   This calculates the coordinates for a move each frame. The angles are way off right now. Probably some int rounding again. Help on this would be appreciated. int VelocityVector::xMove() { double displacement = ((0.0+timy.get_ticks())/(0.0+1000))*speed*cos(double(angle)); return (int)displacement; } int VelocityVector::yMove() { double displacement = ((0.0+timy.get_ticks())/(0.0+1000))*speed*sin(double(angle)); timy.start(); return (int)displacement; }     This uses the previous functions to move the object by changing its coordinates. void Object::move() { setX(getX()+velo->xMove()); setY(getY()+velo->yMove()); }   This is the main function. I've commented the event handling loop and left only this one. There are a lot of preloadings before it but they are not looped and I doubt are causing the freezes. while( quit == false ) { CLS();//this fills the screen with black bg.move(); bg.Render(); UpdateScreen(); }   The image is set to move with a speed 1/10 of the whole screen per second but it lags horibly and moves 10 times slower, sometimes freezing for up to 5-10 seconds.
  4. Thank you. I just figured out the problem. My logic looked like:   while(quit==false) {  move();  while( SDL_PollEvent( &event ) ) {do a lot of stuff including draw();}//no sleeps here }   So I'm just stupid. Forgot that the drawing is inside the second loop There are still a lot of problems though. I simplified it to while(quit == false) { move(); draw(); } Now it moves constantly, but way too slow and lags horribly. Can that be because I have no sleeps in the code The program takes up to 50% of the processor and less than 20 mb ram
  5. I started writing my own simple 2D engine in c++ and SDL and everything worked out great until i tried to implement Frame Independent Movement. I wrote a simple motion function that moves the object with given speed per second((current time - previous move time)/1000 * The Speed). Then I call it it the main loop inside a while. The function itself is buggy but that's not my problem.   The problem is that when i start the program the object do moves and it also moves with close to the desired speed. But only if i feed it inputs. If i stop moving the mouse everything pauses and when I move the mouse again the object continues to move, but without the paused time(meaning it doesn't jump to make up for the lost time).   And that led me to the assumption that I understand nothing about how the program really works. When I create a while(true) and put things in it, how often do these things get called. I always thought they are called as fast as the processor manages to, but it seems I'm wrong.    Is there something more or I just have a nasty bug somewhere and I have to post the code for debugging?