I have this example file that I've been using to get used to the perks of Allegro, but the file is written in an earlier version of Allegro than 4.2.2. There are only a few errors, but I don't know how to fix them! I'll post the code and the compiler output. If it makes any difference(i doubt it), I am using Dev-C++ 4.9.9.2.
#include <allegro.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string>
int backcol;
int groundcol;
int snowcol;
int grav = 1;
int paintcol;
BITMAP *buffer;
std::string paintname = "Snow";
int mx, my, mx2, my2;
int close_b = 0;
int zahler = 1;
int SCREEN_WIDTH;
int SCREEN_HEIGHT;
void thick_line(BITMAP *bmp, int x, int y, int x_, int y_,int thickness, int color){
int dx = x - x_;
int dy = y - y_;
int d = sqrtf(dx * dx + dy * dy);
if (!d)
return;
int v[4 * 2];
v[0] = x - thickness * dy / d;
v[1] = y + thickness * dx / d;
v[2] = x + thickness * dy / d;
v[3] = y - thickness * dx / d;
v[4] = x_ + thickness * dy / d;
v[5] = y_ - thickness * dx / d;
v[6] = x_ - thickness * dy / d;
v[7] = y_ + thickness * dx / d;
polygon(bmp, 4, v, color);
}
void close_button_handler(void)
{
close_b = 1;
zahler = 1;
}
int main()
{
SCREEN_WIDTH = 620;
SCREEN_HEIGHT = 240;
allegro_init();
install_keyboard();
install_mouse();
set_gfx_mode( GFX_AUTODETECT_WINDOWED, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
show_mouse(screen);
set_close_button_callback(close_button_handler);
buffer = create_bitmap(SCREEN_WIDTH, SCREEN_HEIGHT);
BITMAP *outbuf = create_bitmap(SCREEN_WIDTH, SCREEN_HEIGHT);
backcol = makecol( 0, 128, 255);
groundcol = makecol( 0, 128, 50);
snowcol = makecol( 255,255,255);
paintcol = makecol(255,255,255);
clear_to_color ( buffer, backcol);
rectfill(buffer, 0, SCREEN_HEIGHT - 50, SCREEN_WIDTH, SCREEN_HEIGHT, groundcol);
while(!key[KEY_ESC]){
TickPhys(BITMAP *sand_buffer):void{
int c, dir;
for (int y = SCREEN_HEIGHT; y > -1; --y)
{
for(int x = SCREEN_WIDTH; x > -1; --x)
{
if(getpixel(sand_buffer, x, y) == snowcol)
{
dir = (rand()%3 - 1);
if(getpixel(sand_buffer, x+dir, y+grav) == backcol){
putpixel(sand_buffer, x+dir, y+grav, snowcol);
putpixel(sand_buffer, x, y, backcol);
}
else
{
if(getpixel(sand_buffer, x+dir, y+grav) != groundcol){
if(getpixel(sand_buffer, x+dir, y) == backcol){
putpixel(sand_buffer, x+dir, y, snowcol);
putpixel(sand_buffer, x, y, backcol);
}
}
}
}
}
}
return;
}
void creategrains(BITMAP *buffer){
mx2 = mx;
my2 = my;
mx = mouse_x;
my = mouse_y;
if(mouse_b){
if(zahler == 1)
{
zahler =+ 1;
thick_line(buffer, mx2, my2, mx, my, 5, paintcol);
circlefill(buffer, mx, my, 5, paintcol);
}
}
}
void checkselect(){
if(key[KEY_1]){
paintcol = snowcol;
paintname = "Snow";
}
if(key[KEY_2]){
paintcol = groundcol;
paintname = "Ground";
}
if(key[KEY_3]){
paintcol = backcol;
paintname = "Background";
}
if(key[KEY_R]){
paintcol = snowcol;
paintname = "Snow";
clear_to_color ( buffer, backcol);
rectfill(buffer, 0, SCREEN_HEIGHT - 50, SCREEN_WIDTH, SCREEN_HEIGHT, groundcol);
}
}
blit(buffer,outbuf,0,0,0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
std::string msg = "Current Brush: " + paintname;
textout_ex(outbuf, font, msg.c_str(), 10, 10, snowcol, backcol);
textout_ex(outbuf, font, "Press 'R' to Reset", 10, 20, snowcol, backcol);
clear_keybuf();
}
return 0;
}
END_OF_MAIN();
sorry if this doesn't autoformat (i don't know if it auomaitcally does).
Thanks fo any help... i don't really know what to do: change script, plugins, etc.