Hot answers tagged

14

We have a similar case with our RTS Remake. All units and houses are sprites. We have 18 000 sprites for units and houses and terrain, plus another ~6 000 for team colors (applied as masks). Long-stretched we also have some ~30 000 characters used in fonts. So there are some optimizations against RGBA32 atlases you are using: Split into many smaller ...


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

The Problem is that you draw your text on the screen and then blit the doublebuffer over that. Simply change the first argument to textprintf_centre_ex from screen to buffer and it works like a charm.


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 (http://...


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

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

There are a couple of ways to approach this. One is to simply count down from the last time the gun was fired. If you have an update function that gets called every frame, you can do something like: void update(float timeElapsed) { ... cooldown -= timeElapsed; ... } ... void fireShotgun() { if (cooldown <= 0) { createBullets(); ...


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


4

First of all you need to use more, smaller texture atlases. The less textures you have the more difficult and rigid memory management will be. I would suggest a atlas size of 1024, in which case you would have 128 textures instead of 2, or 2048 in which case you would have 32 textures, which you could load and unload as needed. Most games do this resource ...


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 { bullets-...


3

If you use al_wait_for_event, then you need to use a ALLEGRO_TIMER as well to generate pulses (every 1/60th of a second for example) and you update your movement every pulse. That way there is always an event happening on Allegro. If you still don't want to use a timer, you can use al_wait_for_event_until and then specify till when you wait for an event for ...


3

Edit The observed behavior of the ball going through the paddle prompts me to check your collision detection statements, and I believe they are the problem. The condition if (ballx == x + (P1W / 1.0)) will only return true if ballxis exactly equal to a specific point of your paddle. What you want to check is if any part of your ball overlaps any part of ...


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, unlike ...


2

Firstly find the most efficient texture format that you can while still being happy with the visuals of the game whether this is RGBA4444, or DXT compression etc. If you are not happy with the artifacts generated into a DXT alpha compressed image, would it be viable to make the images non-transparent using DXT1 compression for the colour combined with a 4 or ...


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


2

This is by design: rect() is a specifically optimised version for axis-aligned rectangles. I suggest doing two calls to triangle() instead, splitting your rectangle along one of its diagonals.


2

One way to do this is to only run physics and render code when the event queue is empty: ALLEGRO_EVENT_QUEUE* e = al_create_event_queue(); al_register_event_source(e, al_get_keyboard_event_source()); al_register_event_source(e, al_get_mouse_event_source()); al_register_event_source(e, al_get_joystick_event_source()); al_register_event_source(e, ...


1

Wow, that is a hefty amount of animation sprites, generated from 3D models I presume? You really shouldn't be making this game in raw 2D. When you have fixed perspective a funny thing happens, you can seamlessly mix pre-rendered sprites and backgrounds with live-rendered 3D models, that has been used heavily by some games. If you want such fine animations ...


1

I believe that the best approach is to split the texture in many files and loading them on demand. Probably your problem is that you're trying to load larger textures that you would need for a complete 3D scene and you are using Allegro for that. For the big zoom-out you want to be able to apply, you have to use mipmaps. Mipmaps are lower-resolution ...



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