Jump to content
parazitul29

simple allegro graphic

Recommended Posts

Posted (edited)

sunt curios ca pe toate forumurile pe unde l-am postat m-=au acuzat toti ca l-am furat de pe site-uri da nu-si mai amintesc ei site-urile de unde am luat codul ,ce pacat...oricum forumurile alea nu se pot compara cu rst

oricum codul e de cacao nu cred ca are fata de rst..... e cam inutil

o mica explicatie doar deseneaza niste forme, si la primirea unor comenzi se misca fie pe axa x fie pe axa y cum am mai zis programul este foarte simplu doar niste figuri geometrice si miscarea lor, pentru compilarea si rulare aveti nevoie de: Files si selectati de aici ce folositi la dreptunghiul albastru cand il miscati ii ramane si vechia pozitie in spate este din cauza unei greseli dar chestia e ca a inceput sa-mi placa zici ca e paint si am lasat-o asa dar daca nu va place,puneti f2_tempY=f2_y; f2_tempX=f2_x; la incepututl functiei de miscare f2 adica f2Misc() si pe ce sa apasati pentru deplasare e in sursa codului; pentru exemplu: if( key[KEY_X] && bila_x > 0){ --bila_x; adica atunci cand apasam x bila o ia in stanga code


#include <allegro.h>
#include <cstdlib>



int bila_x = 320;
int bila_y = 400;

int bila_tempX = 320;
int bila_tempY = 400;

int f_x = 320;
int f_y = 10;

int f_tempX = 320;
int f_tempY =10;

int f2_x = 330;
int f2_y = 350;

int f2_tempX = 330;
int f2_tempY = 350;


BITMAP *buffer;

void bilaMisc(){



bila_tempY = bila_y;

if( key[KEY_P] && bila_y > 0){

--bila_y;

} else if( key[KEY_O] && bila_y < 420){

++bila_y;

}
bila_tempX = bila_x;

if( key[KEY_X] && bila_x > 0){

--bila_x;

} else if( key[KEY_C] && bila_x < 620){

++bila_x;

}

acquire_screen();
circlefill ( buffer, bila_tempX, bila_tempY, 5, makecol( 0, 0, 0));
circlefill ( buffer, bila_x, bila_y, 5, makecol( 0, 255, 0));
draw_sprite( screen, buffer, 0, 0);
release_screen();



}



void fmisc(){

f_tempY = f_y;

if( key[KEY_W] && f_y > 0){

--f_y;

} else if( key[KEY_S] && f_y < 420){

++f_y;

}

f_tempX=f_x;

if( key[KEY_A] && f_x > 0){

--f_x;

} else if( key[KEY_D] && f_x < 620){

++f_x;

}

acquire_screen();
rectfill( buffer, f_tempX, f_tempY, f_tempX +60, f_tempY+20, makecol ( 0, 0, 0));
rectfill( buffer, f_x, f_y, f_x+60 , f_y+20 , makecol ( 255, 0, 0));
release_screen();

}

void f2Misc(){



if( key[KEY_UP] && f2_y > 0){

--f2_y;

} else if( key[KEY_DOWN] && f2_y < 420){

++f2_y;

}


if( key[KEY_LEFT] && f2_x > 0){

--f2_x;

} else if( key[KEY_RIGHT] && f2_x < 620){

++f2_x;

}

acquire_screen();
rectfill( buffer, f2_tempX, f2_tempY, f2_tempX + 10, f2_tempY + 60, makecol ( 0, 0, 0));
rectfill( buffer, f2_x, f2_y, f2_x + 10, f2_y + 60, makecol ( 0, 0, 255));
release_screen();

}





void praf(){

acquire_screen();
rectfill( buffer, f_x, f_y, f_x + 60, f_y + 10, makecol ( 255, 0, 0));
rectfill( buffer, f2_x, f2_y, f2_x+ 10, f2_y + 60, makecol ( 0, 0, 255));
circlefill ( buffer, bila_x, bila_y, 5, makecol( 0, 255, 0));
draw_sprite( screen, buffer, 0, 0);
release_screen();


}

int main(){

allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);

buffer = create_bitmap( 640, 480);

praf();

while( !key[KEY_ESC]){

bilaMisc();
fmisc();
f2Misc();



}

return 0;

}
END_OF_MAIN();

Edited by parazitul29

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...