Jump to content
  • Advertisement
Sign in to follow this  

making window move with C++ and allegro

This topic is 3324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i am making a small game where objects fly at you and you have to point the mouse and click on them to "shoot" them before they hit you. Each object will start small and get bigger and bigger to look like it is flying at you. For the effect of hitting the player i got the idea of making the whole window "vibrate" by quickly moving the window back and forth and up and down a little bit. This game will not be full screen and just an open window on the computer. Using C++ and allegro how do i control the actual window the game is in? I'm am using windows. Thanks.

Share this post

Link to post
Share on other sites
Include winalleg.h and you can use the win_get_window function, to retrieve a HWND handle to the window. Then use SetWindowPos to change its position.

Simple example:

#include <allegro.h>
#include <winalleg.h>

#pragma comment (lib, "alleg.lib")

int main(int argc, char* argv[]) {
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

HWND hWnd = win_get_window();

RECT rect;
GetWindowRect(hWnd, &rect);

for(int i=0;i<100;i++) {
rect.left + rand()%5,
rect.top + rand()%5,


return 0;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!