Tag Info

Hot answers tagged

7

This is called vsync (vertical sync), which traditionally means that your rendering rate is synchronized with the vertical refresh rate of your monitor to avoid tearing. Nowadays LCD screens don't have "vertical" refresh rates, just simple refresh rates, but it's the same thing. As others have said in the responses, your video card driver settings cause ...


6

First of all, what you're looking for isn't really an engine. You're looking for a graphics API or a graphics API Wrapper to do your drawing. I can recommend SFML. It's a C++ library that manages most of the basic things that everyone needs for you. It features a relatively powerful graphics part which wraps around OpenGL, but also includes basic support ...


5

Based on your description it appears key[LEFT] = false; and key[RIGHT] = false; are never reached. The if-condition for that piece of code reads if(ev.type == ALLEGRO_KEY_UP), however the key down handling code's condition looks like this: if(ev.type == ALLEGRO_EVENT_KEY_DOWN). Without knowing any Allegro, I suggest you use ALLEGRO_EVENT_KEY_UP in the key ...


5

So you have two coordinates or vectors, one is the center of the screen (C from now on) and the other is your object (P from now on.) If you know some math, you might know that a line can be expressed as an origin and a direction vector. The origin is your screen-center, while the direction vector can be found subtracting C from P. This equation can also be ...


5

I'll try to address your specific questions. Is this the best way of drawing a sprite? Is it suitable? It's suitable, and it works, but it's not the best way to do it. What gl* calls really do What you are doing is sending commands to your video card. Just about any function you call that begins with 'gl' does so . Thraka did a fairly good job of ...


5

If I had to choose from that list, I'd definitely gun from SFML as it has a simple API and allows you to implement much of it yourself, a great learning experience. I'd like to just chime in and say SFML is simpler and sticks to what it needs to do. A base framework for rendering things. I think you should also consider the new contender MonoGame ...


4

"He who would learn to fly one day must first learn to stand and walk and run and climb and dance; one cannot fly into flying..." You appear to want to draw a sprite that is always facing the mouse, correct? Then your first task must be to draw a sprite that is always facing something. Pick an arbitrary point and then do the math to draw the sprite so that ...


3

It sounds like a bug with caching glyphs. These sorts of glitches generally are only applicable to video memory, so if you switch to a memory bitmap font by calling this before loading the font you can work around the issue: al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); You'll need to clear the flags after you load the font, or else all subsequent ...


3

You're on the right track; you just need to throw in a system to regulate the timing with which the sprite is updated. The exact model you use is up to you - essentially whatever concept you like working with. In the example I will provide you can specify the speed of the animation in frames per second (independent from the FPS of your game, of course). ...


3

Finding a balance between hardening code against the future and completing your current project is often challenging. You don't want to waste time over-engineering solutions to problems you don't actually have, but you also don't want to create a massive amount of technical debt for yourself. Some practical considerations: Other APIs almost certainly will ...


3

I've never used OpenGL and I'm not that good at the other things I've used in the 3D world. But basically the way programming works in 3D is that you give render instructions to the graphics card. If I interpret your code it's saying glBindTexture(GL_TEXTURE_2D, gl_image); -- I'm going to use this texture glBegin(GL_QUADS); I'm going to draw quads to the ...


3

I see two problems right off the bat, the first has to do with the marked line below: void UpdateBullets() { for(unsigned int index = 0; index < bullets->size(); index++) { if (bullets->at(index)->Y < 0) //<-- HERE { bullets->at(index)->Update(); } else { ...


2

Allegro 5 is quite adept - I like it personally. The initialization code is simple to use, and easy to stuff away in a class or an Init() function. Really, if you write a wrapper function or class, you won't even have to directly call anything from any of these libraries. Are you interested in game graphics or game development? Because if you want to ...


2

The problem you're running into is that 100,000,000 is a big number for a 32-bit floating-point value. There are two approaches to fixing this. First, consider whether you actually need such big unit. Do you really need a world 100,000,000 pixels across? Can you consider a system where 1px == 100m or something along those lines? Simply scaling down your ...


2

I think that the following part of your code is problematic: if(accumulator > accumulator_max) { accumulator = accumulator_max; } You are basically doing a clamp() here, saying that every time difference which exceeds five steps should be disregarded, since accumulator_max = step_duration * 5; Should one iteration of your game loop require more ...


2

g++ allegroTemplate.cpp -o allegroTemplate You aren't linking with Allegro. With Allegro 4, it's recommended to use the allegro-config command, like g++ souce.cpp -o game $(allegro-config --libs) If you are just getting started, you really should take a look at Allegro 5 instead. It has integrated OpenGL support and is actively being developed, ...


2

Without knowing anything about your framwork: You used al_show_native_messagebox and al_show_native_message_box. al_show_native_message_box was used first and does not result in an error so I guess the second one should be al_show_native_message_box too?


2

Running the debugger pointed to the textprintf line being the culprit. You have an extra parameter 10 in there that should not be there. Fixing that solved the problem. HOWEVER, there are other problems with the code: You are using the old version of textprintf use the new version like so: textprintf_ex(screen, font, 0, 0, Text_Color_Red, -1, "Screen ...


2

What you need to do is create a method that gets the amount that the player overlaps the tile by. You would make a copy of this method for each axis. When you are moving the player, you first move the player on the X axis. Then you check for collision. If you find a colliding tile, you get the player's offset into the tile and subtract that from the player's ...


1

You need to know two basic things: The size of your screen, in whatever units you are most comfortable with (that is, tiles or pixels, or whatever -- as long as all your measurements use the same unit you're basically fine). This is essentially the size of the "viewport" into your level or world. The position of the focus point of your view (that is, where ...


1

Okay, I entered -lalleg in the Project/Project Options/Parameters/Compiler and added the lalleg.dll.a library in the Linker and everything turned out alright. Leftium helped with the GFX_AUTODETECT_WINDOWED. The solution was probably made by creating a diffferent project for every individual source code though.


1

You need to define the static variables explicit: static long* xc1; static long* yc1; static long* xc2; static long* yc2; In the implementation file (.cpp), try adding this code: long* Line::xc1 = NULL; long* Line::yc1 = NULL; long* Line::xc2 = NULL; long* Line::yc2 = NULL; More info at: http://www.learncpp.com/cpp-tutorial/811-static-member-variables/ ...


1

Either model will work, and it really ends up depending on the overall structure of your game. While I'm not familiar with allegro specifically, the model that I see most often is the queue model, with a system that looks something like this: //Main game loop while(running) { //Read in all the events from the queue while(eventQueue.hasNext()) { ...


1

I currently use Allegro 4.x, it has some flaws that I had to manually work around, but since then they've released 5.x that overhauled the entire API and fixed all the problems I was having to fix. Allegro 4.x is very stable (as in, no longer being developed) because the entire community suggests that if you are just starting with it that you start with 5.x ...



Only top voted, non community-wiki answers of a minimum length are eligible