How can i solve it?(draw_bitmap)
foretion
#SelectExpand
1movement_character(user_player._player, pos_x+50, pos_y+50, player_direction, action_idx); // user_player._player is ALLEGRO_BITMAP* and initialized with al_load_bitmp(..);

#SelectExpand
1void movement_character(ALLEGRO_BITMAP* bitmap, int dx, int dy, int action_type, int action_idx) { 2 al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); 3 int sx = character_movement[action_type][action_idx][0] * 16; 4 int sy = character_movement[action_type][action_idx][1] * 16; 5 int sw = character_movement[action_type][action_idx][2] * 16; 6 int sh = character_movement[action_type][action_idx][3] * 16; 7 8 //al_draw_bitmap_region(bitmap, sx, sy, sw, sh, dx, dy, 0); 9 ALLEGRO_COLOR tint = al_map_rgb(255, 255, 255); 10 al_draw_tinted_scaled_rotated_bitmap_region(bitmap, sx, sy, sw, sh, tint, 0, 0, dx, dy, GAME_SCALE, GAME_SCALE, 0, 0); // on error

i wrote code.
but show errors..

--------
Assertion failed!

Program: ...nts\projects\nginx\x64\Debug\allegro-debug-5.2.dll
File: C:\dev\allegro_winpkg\universal\all...\transfo...tions.c
Line: 32

Expression: src

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts
--------

what should i check?

Edgar Reynaldo

For some reason your bitmap is NULL.

Make sure it loaded correctly, and that you're not destroying it early.

foretion
#SelectExpand
1void movement_character(ALLEGRO_BITMAP* bitmap, int dx, int dy, int action_type, int action_idx) { 2 al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); 3 int sx = character_movement[action_type][action_idx][0] * 16; 4 int sy = character_movement[action_type][action_idx][1] * 16; 5 int sw = character_movement[action_type][action_idx][2] * 16; 6 int sh = character_movement[action_type][action_idx][3] * 16; 7 8 //al_draw_bitmap_region(bitmap, sx, sy, sw, sh, dx, dy, 0); 9 ALLEGRO_COLOR tint = al_map_rgb(255, 255, 255); 10 al_draw_tinted_scaled_rotated_bitmap_region(al_load_bitmap("gfx/character.png"), sx, sy, sw, sh, tint, 0, 0, dx, dy, GAME_SCALE, GAME_SCALE, 0, 0); // direct al_load_bitmap 11}

the same problem occurs in the this code.
and bitmap is not NULL

:(

-----------
in main.c ( work )
movement_character(.....);

but,

in sock_client_framework.c ( error )
movement_character(.....);

???

Edgar Reynaldo

Most likely you're using a shadowed variable instead of an extern one.

Show more code, like where you declare and define the bitmap objects.

EDIT
Wait, I didn't see the difference between code at first.

If the bitmap is NULL on loading, then you have a problem with the current working directory or filename.

foretion

sock_client_framework.c

#SelectExpand
1// receive packet . . .. 2else if (strcmp(ContentType, "PLAYER") == 0) 3 { 4 const char* userName = json_string_value(json_array_get(pData, 0)); 5 if (strcmp(user_player.cName, userName) == 0) 6 { 7 // get player data from jsonData 8 const int action_type = json_integer_value(json_array_get(pData, 1)); 9 const int player_direction = json_integer_value(json_array_get(pData, 2)); 10 const int action_idx = json_integer_value(json_array_get(pData, 3)); 11 const int pos_x = json_integer_value(json_array_get(pData, 4)); 12 const int pos_y = json_integer_value(json_array_get(pData, 5)); 13 const int hp = json_integer_value(json_array_get(pData, 6)); 14 const int armor = json_integer_value(json_array_get(pData, 7)); 15 const int buf = json_integer_value(json_array_get(pData, 8)); 16 17 ALLEGRO_BITMAP* user_bitmap = al_load_bitmap("gfx/character.png"); 18 //ALLEGRO_BITMAP* hit_efftect = al_load_bitmap("gfx/hit_effect.png"); 19 20 movement_character(al_load_bitmap("gfx/character.png"), pos_x+50, pos_y+50, player_direction, action_idx);

on ERROR.

but main.c

#SelectExpand
1user_player._player = al_load_bitmap("gfx/character.png"); 2// iPos_x, iPos_y .. other parameters initialized too. 3movement_character(user_player._player, user_player.iPos_x, user_player.iPos_y, user_player.iPlayer_direction, user_player.iAction_idx);

worked.

and currently movement_character function in player.c

#SelectExpand
1void movement_character(ALLEGRO_BITMAP* bitmap, int dx, int dy, int action_type, int action_idx) { 2 al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); 3 int sx = character_movement[action_type][action_idx][0] * 16; 4 int sy = character_movement[action_type][action_idx][1] * 16; 5 int sw = character_movement[action_type][action_idx][2] * 16; 6 int sh = character_movement[action_type][action_idx][3] * 16; 7 8 al_draw_bitmap_region(bitmap, sx, sy, sw, sh, dx, dy, 0); 9 //ALLEGRO_COLOR tint = al_map_rgb(255, 255, 255); 10 //al_draw_tinted_scaled_rotated_bitmap_region(bitmap, sx, sy, sw, sh, tint, 0, 0, dx, dy, GAME_SCALE, GAME_SCALE, 0, 0); 11}

:-/

------------

so...Could this be a problem?

#SelectExpand
1// receive packet . . .. 2else if (strcmp(ContentType, "PLAYER") == 0) 3 { 4 const char* userName = json_string_value(json_array_get(pData, 0)); 5 if (strcmp(user_player.cName, userName) == 0) 6 { 7 // get player data from jsonData 8 const int action_type = json_integer_value(json_array_get(pData, 1)); 9 const int player_direction = json_integer_value(json_array_get(pData, 2)); 10 const int action_idx = json_integer_value(json_array_get(pData, 3)); 11 const int pos_x = json_integer_value(json_array_get(pData, 4)); 12 const int pos_y = json_integer_value(json_array_get(pData, 5)); 13 const int hp = json_integer_value(json_array_get(pData, 6)); 14 const int armor = json_integer_value(json_array_get(pData, 7)); 15 const int buf = json_integer_value(json_array_get(pData, 8)); 16 17 ALLEGRO_BITMAP* user_bitmap = al_load_bitmap("gfx/character.png"); 18 //ALLEGRO_BITMAP* hit_efftect = al_load_bitmap("gfx/hit_effect.png"); 19 20 movement_character(al_load_bitmap("gfx/character.png"), pos_x+50, pos_y+50, player_direction, action_idx);

code is in void __cdecl RecvThread(void* p);

and RecvThread called with beginthread.

#SelectExpand
1_beginthread(RecvThread, 0, (void*)serv_sock);

Edgar Reynaldo

Can you post a zip file of your source code and resources please?

It's failing an assertion inside transformations.c in al_copy_transform where the source transform is NULL.

I need to debug this to know exactly why.

I'm guessing it's something to do with threading and displays but I can't say for sure.

foretion

Oh i solved that.

I fixed that implement Without Thread.

But i have other problem.....:(

Edgar Reynaldo

You can make another post or you can just add it here.

Thread #617879. Printed from Allegro.cc