0
我已經構建了一個C++ Allegro貼圖編輯器。其中一個要求是有一個日誌,所以我已經把它放在控制檯窗口中進行每一個動作......現在問題是控制檯窗口在主窗口下(使用GFX_AUTODETECT_WINDOWED),但是每當我嘗試移動該窗口,它只會崩潰程序..我需要能夠移動它並將控制檯窗口移動到並返回到地圖編輯器。任何人有任何想法?C++ Allegro:當我移動窗口時程序崩潰
這是我的代碼的主要部分。
#include <allegro.h>
#include <string>
#include <sstream>
#include "Layout.h"
#include "System.h"
#include "Map.h"
#include <iostream>
#include <fstream>
using namespace std;
// Allegro Functions to stabilize speed
volatile long speed_counter = 0;
void increment_speed_counter() // A function to increment the speed counter
{speed_counter++; }
END_OF_FUNCTION(increment_speed_counter);
int main()
{
System system; // Initialising Allegro
system.Setup();
Map map1; // Creating default map
map1.createMap();
BITMAP *buffer = create_bitmap(24,45); // Double buffering
LOCK_VARIABLE(speed_counter); //Used to set the timer - which regulates the game's
LOCK_FUNCTION(increment_speed_counter);//speed.
install_int_ex(increment_speed_counter, BPS_TO_TIMER(8));//Set our BP
/*game looop */
while(!key[KEY_ESC])
{
clear_bitmap(buffer); // Clear the contents of the buffer bitmap
while(speed_counter > 0)
{
if(mouse_b &1){ // On mouse click
map1.catchMouseEvent(mouse_x, mouse_y);
while(mouse_b & 1){}
}
speed_counter --;
}
rectfill(buffer,0,0,25,45,makecol(135,206,250));
textprintf_ex(buffer, map1.getLayout().getFont(), 0, 0, makecol(255, 255, 255), -1,"%d", map1.getRowVal());
textprintf_ex(buffer, map1.getLayout().getFont(), 0, 20, makecol(255, 255, 255), -1,"%d", map1.getColVal());
blit(buffer, screen, 0, 0, 970, 50, 100, 50);
}
/*Free memory after */
destroy_bitmap(buffer);
return 0;
allegro_exit();
}
END_OF_MAIN();
此外,它確實發生了它本身隨機崩潰而不移動窗口。沒有特定的原因,它只是隨機崩潰。
任何想法的人?
爲什麼在返回0後調用'allegro_exit'? – Marlon