void Proceed() { /* This is a transition effect */ int ScreenWide; RLE_SPRITE *rle0, *rle1; strcpy(FName, "logs/"); strcat(FName, Name); strcat(FName, " - "); strcat(FName, Number); strcat(FName, ".log"); outfile = fopen(FName,"w"); if(Option=='A') { system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &"); rest(5); rle0= get_rle_sprite(Screen1); rle1= get_rle_sprite(Screen2); for(ScreenWide=0; ScreenWide<=1024; ScreenWide=ScreenWide+10) { draw_rle_sprite(screen, rle0, ScreenWide, 0); draw_rle_sprite(screen, rle1, -1024+ScreenWide, 0); } destroy_rle_sprite(rle0); release_screen(); Automatic(); } if(Option=='M') { system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &"); rest(5); rle0= get_rle_sprite(Screen1); rle1= get_rle_sprite(Screen2); for(ScreenWide=0; ScreenWide<=1024; ScreenWide=ScreenWide+10) { draw_rle_sprite(screen, rle0, ScreenWide, 0); draw_rle_sprite(screen, rle1, -1024+ScreenWide, 0); } destroy_rle_sprite(rle0); destroy_rle_sprite(rle1); destroy_bitmap(Screen1); destroy_bitmap(Screen2); release_screen(); Manual(); } release_screen(); }
//Perform frame by frame updates and blits. Set the stream //state to STOP if there are no more frames to update. void RenderToSurface(BITMAP *vscreen) { //update each frame if (g_pSample->Update(0, NULL, NULL, 0) != S_OK) { g_bAppactive = FALSE; g_pMMStream->SetState(STREAMSTATE_STOP); } else { g_bAppactive = TRUE; acquire_screen(); // Because vscreen is a DX Video Bitmap, it can be stretched // onto the screen (also a Video Bmp) but not onto a memory // bitmap (which is what "screen" is when using gfx filters) if (is_video_bitmap(screen)) { stretch_blit(vscreen, screen, 0, 0, vscreen->w, vscreen->h, screen->w / 2 - newWidth / 2, screen->h / 2 - newHeight / 2, newWidth, newHeight); } else { blit(vscreen, vsMemory, 0, 0, 0, 0, vscreen->w, vscreen->h); stretch_blit(vsMemory, screen, 0, 0, vscreen->w, vscreen->h, screen->w / 2 - newWidth / 2, screen->h / 2 - newHeight / 2, newWidth, newHeight); } release_screen(); render_to_screen(screen, 0, 0); // if we're not playing AVI sound, poll the game MP3 if (!useSound) update_polled_stuff_and_crossfade(); } }
void initialise_screen() { if (have_allegro_window) { set_gfx_mode(GFX_SAFE, 320, 200, 0, 0); set_palette(desktop_palette); acquire_screen(); textout_centre(screen, font, "Type Here!!", SCREEN_W/2, SCREEN_H/2-60, 255); textout(screen, font, "Ctrl-M: switch between comm ports", 0, SCREEN_H/2-32, 255); textout(screen, font, "Ctrl-B: send a half second break signal", 0, SCREEN_H/2-16, 255); textout(screen, font, "Ctrl-C: quit", 0, SCREEN_H/2, 255); textout(screen, font, "Other key presses sent to current port.", 0, SCREEN_H/2+16, 255); textout(screen, font, "Current port:", 0, SCREEN_H/2+40, 255); textout(screen, font, cur_port->szName, SCREEN_W/2, SCREEN_H/2+40, 255); release_screen(); } else { printf("Ctrl-M: switch between comm ports\n"); printf("Ctrl-B: send a half second break signal\n"); printf("Ctrl-C: quit\n"); printf("Other key presses sent to current port.\n"); printf("\nCurrent port: %s\n\n", cur_port->szName); } }
void Game :: entry () { std::list <Team *> :: iterator team_i; char key = 0; while (key != 27) { this->draw_screen_buffer(); acquire_screen(); blit(this->screen_buffer->get_bitmap(), screen, 0, 0, 0, 0, this->screen_buffer->get_width(), this->screen_buffer->get_height()); release_screen(); // team turns (run lua scripts) for (team_i = this->teams.begin(); team_i != this->teams.end(); team_i++) (*team_i)->turn(); // move teams for (team_i = this->teams.begin(); team_i != this->teams.end(); team_i++) (*team_i)->process_action(TANK_ACTION_MOVE); // check for flag captures this->check_for_flag_captures(); rest((unsigned int) 200); if (keypressed()) key = (char) readkey(); } }
void draw_palette() { int count = 0; //loop counts int count2 = 0; //[note: as relevant names as could be bothered to make] int count3 = 0; int count4 = 0; int columns = 15; //columns,rows, needed to output all colors in default palette int rows = 15; int startx = 10; //x,y position of color output on screen int starty = 10; int tempy = 10; int color = 0; //starting color to output int pixels = 20; //pixels^2 = size of each square acquire_screen(); for(count4 = 0; count4 <= rows; count4++){ //deals with each row of palette output for(count = 0; count <= columns; count++) { //deals with each column of pallete output starty = tempy; for(count3 = 0; count3 <= pixels; count3++) { //outputs pixels for each sqr row for (count2 = 0; count2 <= pixels; count2++) { //for pixels per sample (square) if (color < 256) { putpixel(screen, startx+count2, starty, color); } } starty++; } starty = tempy; //resets starty to correct row value color++; //increments current palette color startx+=pixels; //increments column, plus relevant no. pixels } startx = 10; //resets column start to ten pixels from left tempy+=pixels; //increments row, plus relevant no. pixels } /*Prints the relevant palette name below main output on screen.*/ if (p==0) { textout_ex(screen, font, "desktop palette", 10, 340, 8, -1); textout_ex(screen, font, "default palette", 10, 340, 13, -1); } else { if (p==1) { textout_ex(screen, font, "default palette", 10, 340, 8, -1); textout_ex(screen, font, "desktop palette", 10, 340, 3, -1); } } release_screen(); }
/* upadate_screen: blit virtualscreen to screen */ void update_screen(void) { assert(vscreen); /* output */ acquire_screen(); blit(vscreen, screen, 0, 0, 0, 0, EDITOR_WIN_W, EDITOR_WIN_H); release_screen(); }
void ss_saver() { PALETTE pal; get_palette(pal); acquire_screen(); save_pcx("ss.pcx", screen, pal); release_screen(); }
// redraw destination pictures void switch_in_callback(void) { acquire_screen(); clear_bitmap(screen); release_screen(); rasta.ShowDestinationBitmap(); rasta.ShowInputBitmap(); }
void moveBall(){ ball_tempX = ball_x; ball_tempY = ball_y; if (dir == 1 && ball_x > 5 && ball_y > 5){ if( ball_x == p1_x + 15 && ball_y >= p1_y && ball_y <= p1_y + 60){ dir = rand()% 2 + 3; }else{ --ball_x; --ball_y; } } else if (dir == 2 && ball_x > 5 && ball_y < 475){ if( ball_x == p1_x + 15 && ball_y >= p1_y && ball_y <= p1_y + 60){ dir = rand()% 2 + 3; }else{ --ball_x; ++ball_y; } } else if (dir == 3 && ball_x < 635 && ball_y > 5){ if( ball_x + 5 == p2_x && ball_y >= p2_y && ball_y <= p2_y + 60){ dir = rand()% 2 + 1; }else{ ++ball_x; --ball_y; } } else if (dir == 4 && ball_x < 635 && ball_y < 475){ if( ball_x + 5 == p2_x && ball_y >= p2_y && ball_y <= p2_y + 60){ dir = rand()% 2 + 1; }else{ ++ball_x; ++ball_y; } } else { if (dir == 1 || dir == 3) ++dir; else if (dir == 2 || dir == 4) --dir; } acquire_screen(); circlefill ( buffer, ball_tempX, ball_tempY, 5, makecol( 0, 0, 0)); circlefill ( buffer, ball_x, ball_y, 5, makecol( 128, 255, 0)); draw_sprite( screen, buffer, 0, 0); release_screen(); rest(5); }
static int loop_callback(void *data) { (void)data; if (gfx_half_width) { acquire_screen(); textout_centre(screen, font, "Music has looped.", gfx_half_width, 36, 10); release_screen(); } return 0; }
static int xm_speed_zero_callback(void *data) { (void)data; if (gfx_half_width) { text_mode(0); /* In case this is overwriting "Music has looped." */ acquire_screen(); textout_centre(screen, font, "Music has stopped.", gfx_half_width, 36, 10); release_screen(); } return 0; }
void refreshscreen() { int y = 0; if (!refresh_needed) return; if (!is_windowed_mode()) y = 40; acquire_screen(); blit(virt_screen, screen, 0, 0, 0, y, 8*term_width, 400); release_screen(); refresh_needed = 0; memset(blit_rect, 0, 4); }
void setupGame() { acquire_screen(); rectfill( buffer, p1_x, p1_y, p1_x + 10, p1_y + 60, makecol ( 0, 0, 255)); rectfill( buffer, p2_x, p2_y, p2_x + 10, p2_y + 60, makecol ( 0, 0, 255)); circlefill ( buffer, ball_x, ball_y, 5, makecol( 128, 255, 0)); draw_sprite( screen, buffer, 0, 0); release_screen(); time(&secs); srand( (unsigned int)secs); dir = rand() % 4 + 1; }
void inform_port_change() { if (have_allegro_window) { acquire_screen(); textout(screen, font, " ", SCREEN_W/2, SCREEN_H/2+40, 255); textout(screen, font, cur_port->szName, SCREEN_W/2, SCREEN_H/2+40, 255); printf("\n\n"); release_screen(); } else { printf("\n\nChanging to port: %s\n\n", cur_port->szName); } }
//--------------------------------------------------------------------------- // Name: draw_csl_dbuff() // Desc: Show the console buffer. //--------------------------------------------------------------------------- void draw_csl_dbuff(BITMAP *csl_dbuff, int csl_y) { acquire_screen(); if((csl_get_y() != csl_y) && (in_the_game)) { draw_level(); blit(csl_dbuff, virt, 0, csl_dbuff->h-csl_y, 0, 0, csl_dbuff->w, csl_y); blit(virt, screen, 0,0,80,0,480,480); } else { blit(csl_dbuff, screen, 0, csl_dbuff->h-csl_y, 80, 0, csl_dbuff->w, csl_y); } release_screen(); }
void p2Move() { p2_tempY = p2_y; if( key[KEY_UP] && p2_y > 0) { --p2_y; } else if( key[KEY_DOWN] && p2_y < 420) { ++p2_y; } acquire_screen(); //rectfill( buffer, p2_tempX, p2_tempY, p2_tempX + 10, p2_tempY + 60, makecol ( 0, 0, 0)); rectfill( buffer, p2_x, p2_y, p2_x + 5, p2_y + 60, makecol ( 0, 0, 0)); rectfill( buffer, p2_x+6, p2_y , p2_x + 10, p2_y + 60, makecol ( 255, 0, 0)); release_screen(); }
void p1Move() { p1_tempY = p1_y; if( key[KEY_W] && p1_y > 0) { --p1_y; } else if( key[KEY_S] && p1_y < 420) { ++p1_y; } acquire_screen(); // rectfill( buffer, p1_tempX, p1_tempY, p1_tempX + 10, p1_tempY + 60, makecol ( 0, 0, 0)); rectfill( buffer, p1_x, p1_y, p1_x + 5, p1_y + 60, makecol ( 255, 0, 0)); rectfill( buffer, p1_x +5 , p1_y , p1_x + 10, p1_y + 60, makecol ( 0, 0, 0)); release_screen(); }
int main(void) { BITMAP *memory_bitmap; int x, y; if (allegro_init() != 0) return 1; install_keyboard(); if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return 1; } } set_palette(desktop_palette); /* make a memory bitmap sized 20x20 */ memory_bitmap = create_bitmap(20, 20); /* draw some circles onto it */ clear_bitmap(memory_bitmap); for (x=0; x<16; x++) circle(memory_bitmap, 10, 10, x, palette_color[x]); /* blit lots of copies of it onto the screen */ acquire_screen(); for (y=0; y<SCREEN_H; y+=20) for (x=0; x<SCREEN_W; x+=20) blit(memory_bitmap, screen, 0, 0, x, y, 20, 20); release_screen(); /* free the memory bitmap */ destroy_bitmap(memory_bitmap); readkey(); return 0; }
int Validate() { acquire_screen(); B1 = load_bitmap("images/Validate/Base01.pcx", pal); B2 = load_bitmap("images/Validate/Base02.pcx", pal); system("mp3blaster sounds/GuacaGuaca.wav&"); while (!key[KEY_ENTER]) { blit(B1, screen, 0, 0, 0, 0, 1024, 768); usleep(400000); blit(B2, screen, 0, 0, 0, 0, 1024, 768); usleep(400000); system("mp3blaster sounds/GuacaGuaca.wav&"); } Register(); release_screen(); return 0; }
void bill_fade_bmp(BITMAP *bmp, int clr) { /* This makes a checkerboard pattern of pixels of a specified color, it can be used to achieve a Windows "shudown" like effect */ int yoff; int ysub; int xoff; int xadd; scare_mouse(); acquire_screen(); for(yoff=0; yoff<=SCREEN_H; yoff +=2) { for(ysub=0; ((yoff-ysub)>=0);ysub++) putpixel(bmp, ysub, yoff-ysub, clr); } for(xoff=0; xoff<=SCREEN_W; xoff +=2) { for(xadd=0; ((xoff+xadd)<=SCREEN_W); xadd++) putpixel(bmp, xoff+xadd, SCREEN_H-xadd, clr); } release_screen(); unscare_mouse(); }
/* draws the spline paths */ void draw_splines(void) { int i; acquire_screen(); clear_to_color(screen, makecol(255, 255, 255)); textout_centre_ex(screen, font, "Spline curve path", SCREEN_W/2, 8, palette_color[255], palette_color[0]); textprintf_centre_ex(screen, font, SCREEN_W/2, 32, palette_color[255], palette_color[0], "Curviness = %.2f", fixtof(curviness)); textout_centre_ex(screen, font, "Up/down keys to alter", SCREEN_W/2, 44, palette_color[255], palette_color[0]); textout_centre_ex(screen, font, "Space to walk", SCREEN_W/2, 68, palette_color[255], palette_color[0]); textout_centre_ex(screen, font, "C to display control points", SCREEN_W/2, 92, palette_color[255], palette_color[0]); textout_centre_ex(screen, font, "T to display tangents", SCREEN_W/2, 104, palette_color[255], palette_color[0]); for (i=1; i<node_count-2; i++) draw_spline(nodes[i], nodes[i+1]); for (i=1; i<node_count-1; i++) { draw_node(i); if (show_tangents) { line(screen, nodes[i].x - fixtoi(fixcos(nodes[i].tangent) * 24), nodes[i].y - fixtoi(fixsin(nodes[i].tangent) * 24), nodes[i].x + fixtoi(fixcos(nodes[i].tangent) * 24), nodes[i].y + fixtoi(fixsin(nodes[i].tangent) * 24), palette_color[1]); } } release_screen(); }
void draw() { for(unsigned int i=0;i<8;++i) { GSVECTOR temp=GSVector3TransformCoord(vertices[i], view); //std::cout<<"camera 3d="<<temp<<std::endl; GSVECTOR temp1=GSVector3TransformCoord(temp,p)/temp.getW(); _2Dpoints[i]=temp1/temp1.getW(); //std::cout<<temp.getW()<<std::endl; //std::cout<<_2Dpoints[i]<<std::endl; } /* for(unsigned int i=0;i<8;++i) { std::cout<<"X="<<static_cast<unsigned int>((_2Dpoints[i].getX()+2/2)*1920/2)<<" Y="<<static_cast<unsigned int>((2/2-_2Dpoints[i].getY())*1200/2)<<std::endl; }*/ acquire_screen(); clear_to_color( buffer, makecol( 255, 255, 255)); for(unsigned int i=0;i<12;++i) { line( buffer, static_cast<unsigned int>((_2Dpoints[line_indices[i][0]].getX()+2/2)*1920/2), static_cast<unsigned int>((2/2-_2Dpoints[line_indices[i][0]].getY())*1200/2), static_cast<unsigned int>((_2Dpoints[line_indices[i][1]].getX()+2/2)*1920/2), static_cast<unsigned int>((2/2-_2Dpoints[line_indices[i][1]].getY())*1200/2), makecol(0,0,0) ); } draw_sprite( screen, buffer, 0, 0); release_screen(); }
void moveCircle(){ tempX = x; tempY = y; dir = rand() % 4 + 1; if (dir == 1 && x != 20 && y != 20){ --x; --y; } else if (dir == 2 && x != 20 && y != 460){ --x; ++y; } else if (dir == 3 && x != 620 && y != 20){ ++x; --y; } else if (dir == 4 && x != 620 && y != 460){ ++x; ++y; } acquire_screen(); circlefill ( screen, tempX, tempY, 20, makecol( 0, 0, 0)); circlefill ( screen, x, y, 20, makecol( 255, 0, 0)); release_screen(); rest(10); }
void Draw(int cycles, int currtour, int besttour) { ///////////////////////////////////////////////////////////////////////////////////////////// // draw a graph (drawing towns and paths is too hard with the current system of random distances) // is graph of tour length at each step as well as the current best tour length // // One important thing with draw() is that it takes the current and best tour lengths and divides them // by the number of towns.. this is so that no matter how many towns there are, it wont draw off the screen // unless the MAX_DISTANCE is set over 500 // ///////////////////////////////////////////////////////////////////////////////////////////// acquire_screen(); //graph axis vline(screen, 40, 40, SCREEN_H-40, makecol(255,255,255)); hline(screen, 40, 440, SCREEN_W-40, makecol(255,255,255)); //graph axis text textout_centre(screen,font,"CYCLES",SCREEN_W/2, SCREEN_H-20,makecol(0,200,200)); textout(screen,font,"DISTANCE",1, SCREEN_H/2,makecol(0,200,200)); //graph legend rectfill(screen, SCREEN_W-200, 20, SCREEN_W-170, 40, makecol(0,200,200)); textprintf(screen,font,SCREEN_W-160, 30,makecol(255,255,255),"Current Tour"); rectfill(screen, SCREEN_W-200, 50, SCREEN_W-170, 70, makecol(255,0,0)); textprintf(screen,font,SCREEN_W-160, 60,makecol(255,255,255),"Best Tour"); //draw current cycles distance vline(screen,cycles+41,SCREEN_H-40,(SCREEN_H-40)-(currtour/NUM_TOWNS),makecol(0,200,200)); vline(screen,cycles+41,SCREEN_H-40,(SCREEN_H-40)-(besttour/NUM_TOWNS),makecol(255,0,0)); release_screen(); }
int main (void) { /* initialize the game. */ setup_allegro (MODE, WIDTH, HEIGHT, 16); setup_bmps(); setup_player(); scrollx = 0; scrolly = 0; currentmap = (MAP*)malloc (sizeof (MAP)); currentmap->initflag = 1; currentmap->idnumber = TCA_13; map_handler(); while (!key[KEY_ESC]) { get_input(); move_player(); scroll_window(); animate_player(); map_event_handler(); map_handler(); draw_player(); blit (scrollbmp, bufferbmp, scrollx, scrolly, 0, 0, WIDTH-1, HEIGHT-1); print_scroll_debug_messages(); print_player_debug_messages(); acquire_screen(); blit (bufferbmp, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1); release_screen(); rest (20); } destroy_bmps(); allegro_exit(); return 0; }
int main(int argc, const char *const *argv) /* I'm const-crazy! */ { DUH *duh; /* Encapsulates the music file. */ AL_DUH_PLAYER *dp; /* Holds the current playback state. */ /* Initialise Allegro */ if (allegro_init()) return EXIT_FAILURE; /* Check that we have one argument (plus the executable name). */ if (argc != 2) usage(argv[0]); /* Tell Allegro where to find configuration data. This means you can * put any settings for Allegro in dumb.ini. See Allegro's * documentation for more information. */ set_config_file("dumb.ini"); /* Initialise Allegro's keyboard input. */ if (install_keyboard()) { allegro_message("Failed to initialise keyboard driver!\n"); return EXIT_FAILURE; } /* This function call is appropriate for a program that will play one * sample or one audio stream at a time. If you have sound effects * too, you may want to increase the parameter. See Allegro's * documentation for details on what the parameter means. Note that * newer versions of Allegro act as if set_volume_per_voice() was * called with parameter 1 initially, while older versions behave as * if -1 was passed, so you should call the function if you want * consistent behaviour. */ set_volume_per_voice(0); /* Initialise Allegro's sound output system. */ if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL)) { allegro_message("Failed to initialise sound driver!\n%s\n", allegro_error); return EXIT_FAILURE; } /* dumb_exit() is a function defined by DUMB. This operation arranges * for dumb_exit() to be called last thing before the program exits. * dumb_exit() does a bit of cleaning up for you. atexit() is * declared in stdlib.h. */ atexit(&dumb_exit); /* DUMB defines its own wrappers for file input. There is a struct * called DUMBFILE that holds function pointers for the various file * operations needed by DUMB. You can decide whether to use stdio * FILE objects, Allegro's PACKFILEs or something else entirely. No * wrapper is installed initially, so you must call this or * dumb_register_stdfiles() or set up your own before trying to load * modules by file name. (If you are using another method, such as * loading an Allegro datafile with modules embedded in it, then DUMB * never opens a file by file name so this doesn't apply.) */ dumb_register_packfiles(); /* Load the module file into a DUH object. Quick and dirty: try the * loader for each format until one succeeds. Note that 15-sample * mods have no identifying features, so dumb_load_mod() may succeed * on files that aren't mods at all. We therefore try that one last. */ duh = dumb_load_it(argv[1]); if (!duh) { duh = dumb_load_xm(argv[1]); if (!duh) { duh = dumb_load_s3m(argv[1]); if (!duh) { duh = dumb_load_mod(argv[1]); if (!duh) { allegro_message("Failed to load %s!\n", argv[1]); return EXIT_FAILURE; } } } } /* Read the quality values from the config file we told Allegro to * use. You may want to hardcode these or provide a more elaborate * interface via which the user can control them. */ dumb_resampling_quality = get_config_int("sound", "dumb_resampling_quality", 4); dumb_it_max_to_mix = get_config_int("sound", "dumb_it_max_to_mix", 128); /* If we're not in DOS, show a window and register our close hook * function. */ # ifndef ALLEGRO_DOS { const char *fn = get_filename(argv[1]); gfx_half_width = strlen(fn); if (gfx_half_width < 22) gfx_half_width = 22; gfx_half_width = (gfx_half_width + 2) * 4; /* set_window_title() is not const-correct (yet). */ set_window_title((char *)"DUMB Music Player"); if (set_gfx_mode(GFX_DUMB_MODE, gfx_half_width*2, 80, 0, 0) == 0) { acquire_screen(); textout_centre(screen, font, fn, gfx_half_width, 20, 14); textout_centre(screen, font, "Press any key to exit.", gfx_half_width, 52, 11); release_screen(); } else gfx_half_width = 0; } /* Silly check to get around the fact that someone stupidly removed * an old function from Allegro instead of deprecating it. The old * function was put back a version later, but we may as well use the * new one if it's there! */ # if ALLEGRO_VERSION*10000 + ALLEGRO_SUB_VERSION*100 + ALLEGRO_WIP_VERSION >= 40105 set_close_button_callback(&closehook); # else set_window_close_hook(&closehook); # endif # endif /* We want to continue running if the user switches to another * application. */ set_display_switch_mode(SWITCH_BACKGROUND); /* We have the music loaded, but it isn't playing yet. This starts it * playing. We construct a second object, the AL_DUH_PLAYER, to * represent the playing music. This means you can play the music * twice at the same time should you want to! * * Specify the number of channels (2 for stereo), which 'signal' to * play (always 0 for modules), the volume (1.0f for default), the * buffer size (4096 generally works well) and the sampling frequency * (ideally match the final output frequency Allegro is using). An * Allegro audio stream will be started. */ dp = al_start_duh(duh, 2, 0, 1.0f, get_config_int("sound", "buffer_size", 4096), get_config_int("sound", "sound_freq", 44100)); /* Register our callback functions so that they are called when the * music loops or stops. See docs/howto.txt for more information. * There is no threading issue: DUMB will only process playback * in al_poll_duh(), which we call below. */ { DUH_SIGRENDERER *sr = al_duh_get_sigrenderer(dp); DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sr); dumb_it_set_loop_callback(itsr, &loop_callback, NULL); dumb_it_set_xm_speed_zero_callback(itsr, &xm_speed_zero_callback, NULL); } /* Main loop. */ for (;;) { /* Check for keys in the buffer. If we get one, discard it * and exit the main loop. */ if (keypressed()) { readkey(); break; } /* Poll the music. We exit the loop if al_poll_duh() has * returned nonzero (music finished) or the window has been * closed. al_poll_duh() might return nonzero if you have set * up a callback that tells the music to stop. */ if (al_poll_duh(dp) || closed) break; /* Give other threads a look-in, or allow the processor to * sleep for a bit. YIELD() is defined further up in this * file. */ YIELD(); } /* Remove the audio stream and deallocate the memory being used for * the playback state. We set dp to NULL to emphasise that the object * has gone. */ al_stop_duh(dp); dp = NULL; /* Free the DUH object containing the actual music data. */ unload_duh(duh); duh = NULL; /* All done! */ return EXIT_SUCCESS; }
/* moves a sprite along the spline path */ void walk(void) { #define MAX_POINTS 256 int points[8]; int x[MAX_POINTS], y[MAX_POINTS]; int n, i; int npoints; int ox, oy; acquire_screen(); clear_to_color(screen, makecol(255, 255, 255)); for (i=1; i<node_count-1; i++) draw_node(i); release_screen(); do { poll_mouse(); } while (mouse_b); clear_keybuf(); ox = -16; oy = -16; xor_mode(TRUE); for (n=1; n < node_count-2; n++) { npoints = (fixtoi(node_dist(nodes[n], nodes[n+1]))+3) / 4; if (npoints < 1) npoints = 1; else if (npoints > MAX_POINTS) npoints = MAX_POINTS; get_control_points(nodes[n], nodes[n+1], points); calc_spline(points, npoints, x, y); for (i=1; i<npoints; i++) { vsync(); acquire_screen(); circlefill(screen, ox, oy, 6, palette_color[2]); circlefill(screen, x[i], y[i], 6, palette_color[2]); release_screen(); ox = x[i]; oy = y[i]; poll_mouse(); if ((keypressed()) || (mouse_b)) goto getout; } } getout: xor_mode(FALSE); do { poll_mouse(); } while (mouse_b); clear_keybuf(); }
int Manual() { int PVi, k; K= uatof(Gain); /* Things will be drawn more quickly if you always acquire the screen before trying to draw onto it. */ acquire_screen(); Graphics(); /* Call to graphics from a different function to avoid messy code */ int dir = 1; //since we are receiving data, direction should be 1 int mode = IEEE1284_MODE_COMPAT; // parameter to set mode 'receive' RLE_SPRITE *rle; /* Set the direction for reception */ ioctl(fd, PPDATADIR, &dir); ioctl(fd, PPWDATA, 0); PVi= 0; k= 100; M=0; while (!key[KEY_ESC]) /* Only pressing ESC can Exit */ { M++; /* Check if user needs some help */ if(key[KEY_F1]) Help(); k++; i= 897; Captura = create_sub_bitmap(screen, 72, 350, 898, 368); rle = get_rle_sprite(Captura); destroy_bitmap(Captura); draw_rle_sprite(screen, rle, 71, 350); destroy_rle_sprite(rle); /* This line reads data from the interfase which is the process variable(measured variable) of the system */ ioctl(fd, PPRDATA, &PVi); PV= PVi; if(PV<=40) { PV= 51; system("festival --tts Messages/Disconnected&"); blit(Disconnected, screen, 0, 0, 70, 290, 887, 52); } if(PV<=48) PVi= 51; PV= 1.794117647*(PVi-51); SP= PV; if(key[KEY_RIGHT]) { fd = close("/dev/parport0"); Simulator(); } if(key[KEY_PGUP]) OP= (OP+46); if(key[KEY_PGDN]) OP= (OP-46); if(key[KEY_UP]) OP= (OP+3.66); if(key[KEY_DOWN]) { if(OP>=1) OP= (OP-3.66); } if(key[KEY_PRTSCR]) { Captura = create_sub_bitmap(screen, 0, 0, 1024, 768); save_bitmap("images/User/Captura.pcx", Captura, pal); destroy_bitmap(Captura); } Timer++; if(OP<=0) OP= 0; if (PV>=40) { textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100); // Medición textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100); // SP textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100); // Controlador } if(k>=100) { k= 0; vline(screen, 967, 351, 717, GRAY); blit(Clean, screen, 0, 0, 968, 350, 2, 368); } int Recorder; Recorder++; if(Recorder>=900) { Recorder= 0; Captura = create_sub_bitmap(screen, 258, 350, 715, 368); } Captura = create_sub_bitmap(screen, 248, 350, 705, 368); if(PV>=362) PV= 365; if(OP>=367) OP= 365; if(PV<=0) PV= 0; if(OP<=0) OP= 0; /* Draw the behaviour of the PV, SP and OP over time */ line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED); PVj= PV; /* Flag for line y2 as a precedent state */ line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE); OPj= OP; /* Flag for line y2 as a precedent state */ fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100)); rest(Delay); } int ScreenWide; RLE_SPRITE *rle0, *rle1; BITMAP *Screen3; Screen3 = load_bitmap("images/Close/Base.pcx", pal); system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &"); rest(5); rle0= get_rle_sprite(Screen2); rle1= get_rle_sprite(Screen3); for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5) { draw_rle_sprite(screen, rle0, 0, 768); draw_rle_sprite(screen, rle1, 0, -768+ScreenWide); } destroy_rle_sprite(rle0); destroy_rle_sprite(rle1); destroy_bitmap(Screen2); destroy_bitmap(Screen3); destroy_bitmap(Clean); destroy_bitmap(Disconnected); release_screen(); Close(); exit(0); }
int main(int argc, char *argv[]) {//start of main function //set gameover = true to stop the game from loading before the player plays GAMEOVER=true; //variable declerations int id; //variables used for the threads pthread_t pthread0; pthread_t pthread1; int threadid0 = 0; int threadid1 = 1; int threadid2 = 2; int threadid3 = 3; int threadid4 = 4; int threadid5 = 5; int threadid6 = 6; //set is intro to true to play the intro bool inIntro =true; //variable used to display the players message char *playermessage; //map variables int mapxoff = 0; int mapyoff = 0; //game speed variables declerations and initalization int frames_per_sec=0; int frames_done=0; int old_time =0; int totaltime=0; //declare allegro variables //BITMAP *buffer; BITMAP *intro; //initalize the classes //player *owl; sprite *hearts[3]; sprhandler = new spritehandler(); snake *snakeboss; //initalize allegro allegro_init(); install_keyboard(); install_timer(); set_keyboard_rate(1000,1000); install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL); //initalize the screen set_color_depth(COLORDEPTH); set_gfx_mode(MODE,WIDTH,HEIGHT,0,0); //lock both the varibale and the funciton to be used by the interrupt handler LOCK_VARIABLE(ticks); LOCK_FUNCTION(ticker); //install the interrupt handler which calls the ticker 60 times a second install_int_ex(ticker,BPS_TO_TIMER(FPS)); //lock both the varibale and the funciton to be used by the interrupt handler //these LOCK_VARIABLE(gametime); LOCK_FUNCTION(game_time_ticker); //install the interrupt handler which calls the game time ticker //game time ticker is in 10ths of seconds install_int_ex(game_time_ticker,BPS_TO_TIMER(10)); //create back buffer buffer = create_bitmap(SCREEN_W, SCREEN_H); //create the intro screen by loading the bitmap into the intro buffer intro = load_bitmap("flightless title.bmp",NULL); if(!intro){ allegro_message("Error loading intro image"); return 1; } //seed the random function srand(time(NULL)); //load fonts FONT *dicot_22_font; PALETTE palette; //load the the font for the header of the application dicot_22_font = load_font("dicot_22.pcx", palette, NULL); //load and display the intro screen while(inIntro) { //display the intro screen for the game blit(intro,screen,0,0,0,0,SCREEN_W,SCREEN_H); //wait for the player to press enter to start the game if(key[KEY_ENTER]){ inIntro=false; GAMEOVER=false; } //if the player presses esc then exit the game and the intro if(key[KEY_ESC]){ inIntro=false; GAMEOVER=true; } } //for as many badies make sprites to hold the bugs for(int i=0;i<BADIES;i++) { //initalize the bug sprite bug[i] = new bugs(); //load the bug sprite sheet if(!bug[i]->load("bug.bmp")){ allegro_message("Error loading bug sprite"); return 1; } //initalize the bug propertys bug[i]->init(); //add sprites to the sprite handler sprhandler->addbugs(bug[i]); } //initalize the player owl = new player(); //load the players sprite sheet if(!owl->load("owl sprite_new.bmp")){ allegro_message("Error loading owl sprite"); return 1; } //initalize the sprite properties owl->init(); //add the player object to the sprite handler sprhandler->addsprite(owl); //create the new snake object snakeboss = new snake(); //load the snake if(!snakeboss->load("snake_Tiles.bmp")){ allegro_message("Error loading snake sprite"); return 1; } //initalize the snake snakeboss->init(); //snakeboss->alive=false; //add the snake to the sprite handler sprhandler->addboss(snakeboss); //create for loop to load the players health indicator for(int i=1;i<4;i++) { //create new sprite objects to hold the images hearts[i-1] = new sprite(); //load the players health image if(!hearts[i-1]->load("FullHealth.bmp")){ allegro_message("Error loading player Health"); return 1; } //set sprite properties hearts[i-1]->x = SCREEN_W-35*i; hearts[i-1]->y = 10; hearts[i-1]->width = 30; hearts[i-1]->height = 30; hearts[i-1]->velx = 0; hearts[i-1]->vely = 0; hearts[i-1]->animcolumns = 0; hearts[i-1]->curframe = 0; hearts[i-1]->totalframes =1; hearts[i-1]->animdir = 0; //object type of non moving sprite hearts[i-1]->objecttype=2; hearts[i-1]->alive=0; //add the players health to the sprite handler sprhandler->addsprite(hearts[i-1]); } //create the music samples SAMPLE *ingamesong; //load the wav file into the samples //main game soundtrack ingamesong=load_sample("melo-24_Clip.wav"); if(ingamesong==NULL){ allegro_message("Error loading game soundtrack"); return 1; } //use mappy.h global function MapLoad to load the .FMP file MapLoad("flightless.FMP"); //play the sample music int playing = play_sample(ingamesong,150,125,1000,true); //start the clock to time the player startTime = time(NULL); //create the thread for player id = pthread_create(&pthread0, NULL, playerdraw_thread, (void*)&threadid5); //create the thread for the bugs id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid0); id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid1); id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid2); id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid3); id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid4); //create the thread to draw the snake id = pthread_create(&pthread1, NULL, snakedraw_thread, (void*)&threadid0); //main game loop while (!GAMEOVER) { while (ticks==0) { rest(1); } while(ticks>0) { if(key[KEY_ESC]) { playermessage="You quit :( Please come back again."; GAMEOVER=true; } //get the previous value of ticks and store them old_ticks=ticks; //each time we hit this loop we increment the mapxoffset +1 if(mapxoff<mapwidth*mapblockwidth) { //if the player is not hiding update the map if(owl->state!=2) { mapxoff++; } } //draw the background tiles via the mappy global funciton MapDrawBG MapDrawBG(buffer,mapxoff,0,0,0,WIDTH-1,HEIGHT-1); //draw the players health indicator based on the owls health/30 for (int i=0;i<((owl->health)/30);i++) { hearts[i]->draw(buffer); } //lock the varibales to protect them from the unsynced threads pthread_mutex_lock(&threadsafe); //get the player input owl->getinput(); sprhandler->updatebugs(); sprhandler->updatesnake(); //decrement the ticks ticks--; //unlock the mutex pthread_mutex_unlock(&threadsafe); //if the logic is taking too long abort and draw the screen if(old_ticks<=ticks) break; } //for every second that passess we need to call this function if(gametime - old_time >= 10) { //frames_per_sec holds the number of frames drawn in the last sec frames_per_sec = frames_done; //reset these variables for the next second frames_done =0; old_time=gametime; } //Decrement the players health if(gametime%120==0) { owl->takedamage(2); } if(sprhandler->getsnakes(0)->alive==false && gametime%400==0) { sprhandler->getsnakes(0)->resurrect(); } //check players health if(owl->health<=0) { playermessage="You have died...please remeber to eat next time."; GAMEOVER=true; } //stop the window from scrolling if(GAMEOVER==true ||mapxoff>=mapwidth*mapblockwidth-WIDTH) { if(mapxoff>=mapwidth*mapblockwidth-WIDTH) playermessage="Great job player you passed the game! Way to go."; //stop the map from moving mapxoff=mapwidth*mapblockwidth-WIDTH; //stop the music from playing stop_sample(ingamesong); //create the music samples SAMPLE *cheer=NULL; //load the wav file into the sample cheer=load_sample("app.wav"); if(cheer==NULL){ allegro_message("Error loading game soundtrack"); return 1; } //play the sample music play_sample(cheer,255,125,1000,true); //message the player...even if they are a quiter! textprintf_ex(screen,dicot_22_font,200,SCREEN_H/2,makecol(255,0,0),-1,playermessage); rest(2000); GAMEOVER=true; } //show frames fer second on the screen by pressing "cntrl f" if(key[KEY_F]) { if(key_shifts & KB_CTRL_FLAG) { //switch the showFPS flag to display the FPS SHOWFPS=!SHOWFPS; } //SHOWFPS=SHOWFPS; } if(SHOWFPS==true) textprintf_ex(buffer,font,20,20,WHITE,0,"frames= :%d",frames_per_sec); if(key[KEY_H]) { if(key_shifts & KB_CTRL_FLAG) { //switch the SHOWHEALTH flag to display the FPS SHOWHEALTH=!SHOWHEALTH; } //SHOWHEALTH=SHOWHEALTH; } //update the screen using a double buffering technique acquire_screen(); blit(buffer,screen,0,0,0,0,WIDTH,HEIGHT); release_screen(); //everytime we bilt from buffer to screen increase frames_done frames_done++; } //find the time that the game ended endTime = time(NULL); //kill the mutex (thread protection) pthread_mutex_destroy(&threadsafe); //call to create the final image to present to the user create_close(buffer,dicot_22_font,owl); //Garbage Collection clean up all of the objects that are being used in memory remove_keyboard(); remove_timer(); //destory the bitmaps that we are using destroy_bitmap(buffer); destroy_bitmap(intro); //destroy the map MapFreeMem(); //delete the sprites delete sprhandler; //call to allegro exit allegro_exit(); return 0; }//end of main
int main( int argc, char *argv[] ) { BITMAP *lobuf; BITMAP *backbuf; #ifndef NDEBUG // Create a win32 console for printfing AllocConsole(); freopen("CONIN$","rb",stdin); // reopen stdin handle as console window input freopen("CONOUT$","wb",stdout); // reopen stout handle as console window output freopen("CONOUT$","wb",stderr); // reopen stderr handle as console window output #endif //----- Game stuff --------------- // the map of the world TileMap map( 300 ); // the chunks of land std::vector<TileMap*> landChunks; set_color_depth( 32 ); if (allegro_init() != 0) return 1; install_keyboard(); install_timer(); install_mouse(); // install ticker LOCK_VARIABLE( ticks ); LOCK_FUNCTION( ticker ); install_int_ex( ticker, BPS_TO_TIMER( UPDATES_PER_SEC ) ); if (set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ) != 0) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "Unable to set graphics mode:\n%s\n", allegro_error ); return 1; } enable_hardware_cursor(); select_mouse_cursor( MOUSE_CURSOR_ARROW ); lobuf = create_bitmap( 320, 240 ); backbuf = create_bitmap( SCREEN_W, SCREEN_H ); show_mouse( backbuf ); // printf("lobuf %p backbuf %p\n", lobuf, backbuf ); // init gameplay stuff srand( time(0)); //printf("init map...\n" ); map.init(); map.reset(); map.do_water = true; message( "I woke near the ocean. I didn't even know my own name." ); message( "So I started exploring (drag RMB to scroll)"); // load chunks loadLandChunks( "gamedata/land.txt", landChunks ); map.paste( landChunks[0], 148, 148 ); map.enableSelect( lobuf ); // make player BITMAP *npcCodeMask = load_bitmap( "gamedata/code_npc.bmp", NULL ); BITMAP *critterCodeMask = load_bitmap( "gamedata/code_critter.bmp", NULL ); BITMAP *playerBmp = make_pixbot( npcCodeMask ); // Init game objects std::vector<GameObj*> gameObjs; Player *player = new Player(); player->m_bmp = playerBmp; player->m_x = 150; player->m_y = 148; gameObjs.push_back( player ); int currTool = Tool_WALK; //printf("--- mainloop\n" ); bool done = false; bool dbgShowSelects = false; // near center on a 300x300 map int view_x = -1644, view_y = -800; bool dragging = false; int drag_x, drag_y; int view_drag_x, view_drag_y; int mouse_x2, mouse_y2; // in lobuf coords int last_b = 0; int px, py; bool doGenerate = true; while (!done) { // handle ticks -- give the ticker a chance to start while( ticks==0) { rest(100 / UPDATES_PER_SEC ); } while ( ticks > 0) { int old_ticks = ticks; //=== Update ==== map.m_wave_offs++; if (messageTime>0) { messageTime--; if (messageTime==0) { strcpy( messageText, "" ); } } else { if (!messageQueue.empty()) { strcpy( messageText, messageQueue.front().c_str() ); messageQueue.pop_front(); messageTime = MSG_TIME; } } for (int i=0; i < gameObjs.size(); ++i ) { if (gameObjs[i]) { gameObjs[i]->update( map, gameObjs ); } } // update may have NULL'd objects std::vector<GameObj*>::iterator removed; removed = std::remove( gameObjs.begin(), gameObjs.end(), (GameObj*)NULL ); gameObjs.erase( removed, gameObjs.end() ); // update bubbles for (int i=0; i < bubbles.size(); i++) { bubbles[i]->bub_age += 1.0 / (float)UPDATES_PER_SEC; } ticks--; if (old_ticks <= ticks) break; } int dropBubble = -1; // keyboard input if (keypressed()) { int k = readkey(); if (cheatsEnabled) { switch(k>>8) { //---- debug keys case KEY_F5: dbgShowSelects = !dbgShowSelects; break; case KEY_F6: playerBmp = make_pixbot( npcCodeMask ); player->m_bmp = playerBmp; break; case KEY_F7: bubbles.push_back( create_bubble( landChunks ) ); break; } } switch(k>>8) { case KEY_F11: cheatsEnabled = true; message("Cheats enabled."); break; //---- game keys case KEY_1: dropBubble = 0; break; case KEY_2: dropBubble = 1; break; case KEY_3: dropBubble = 2; break; case KEY_4: dropBubble = 3; break; case KEY_5: dropBubble = 4; break; // hack -- on keydown, clear walk wait counter case KEY_LEFT: case KEY_RIGHT: case KEY_UP: case KEY_DOWN: player->walk_c = 0; break; } } if ((dropBubble >= 0) && (dropBubble < bubbles.size()) ) { TileMap *bub = bubbles[dropBubble]; bubbles[dropBubble] = bubbles[ bubbles.size() -1 ]; bubbles.pop_back(); map.paste( bub, player->m_x - bub->m_size/2, player->m_y - bub->m_size/2 ); doGenerate = true; delete bub; } // generate entities if (doGenerate) { doGenerate = false; for (int i=0; i < map.m_size; i++) { for (int j=0; j < map.m_size; j++) { if (map.map(i,j).m_gen != Gen_NONE ) { if (map.map(i,j).m_gen == Gen_BUBBLE) { BubbleObj *bubObj = new BubbleObj(); bubObj->m_x = i; bubObj->m_y = j; bubObj->m_bub = create_bubble( landChunks ); bubObj->m_bmp = create_bitmap( 15, 15 ); BITMAP *bubBmp = bubObj->m_bub->bub_bmp; stretch_blit( bubBmp, bubObj->m_bmp, 0,0, bubBmp->w, bubBmp->h, 0,0, 15, 15 ); gameObjs.push_back( bubObj ); } else if (map.map(i,j).m_gen == Gen_CRITTER) { CritterObj *critObj = new CritterObj(); critObj->m_x = i; critObj->m_y = j; BITMAP *critpic; int critNdx = rand() % (critterBmps.size()+1); if (critNdx == critterBmps.size()) { // yay new critter critpic = make_pixbot( critterCodeMask ); critterBmps.push_back( critpic ); } else { critpic = critterBmps[ critNdx ]; } critObj->m_bmp = critpic; gameObjs.push_back( critObj ); } else if (map.map(i,j).m_gen == Gen_NPC) { NpcObj *npc = new NpcObj(); npc->m_x = i; npc->m_y = j; npc->m_bmp = make_pixbot( npcCodeMask ); gameObjs.push_back( npc ); } map.map(i,j).m_gen = Gen_NONE; } } } } // check for quit if (key[KEY_ESC]) { exit(0); break; } player->walk_x = 0; player->walk_y = 0; if (key[KEY_UP] && !key[KEY_DOWN]) { player->walk_x = 0; player->walk_y = 1; } else if (!key[KEY_UP] && key[KEY_DOWN]) { player->walk_x = 0; player->walk_y = -1; } else if (!key[KEY_LEFT] && key[KEY_RIGHT]) { player->walk_x = -1; player->walk_y = 0; } else if (key[KEY_LEFT] && !key[KEY_RIGHT]) { player->walk_x = 1; player->walk_y = 0; } // Map cursor char buff[246]; int mapX, mapY; map.clearSelected(); mouse_x2 = mouse_x/2; mouse_y2 = mouse_y/2; if (map.screenToMap( mouse_x2, mouse_y2, mapX, mapY )) { sprintf( buff, "V %d %d x y %d %d [%d] -- map %d %d", view_x, view_y, mouse_x, mouse_y, mouse_b, mapX, mapY ); // NOTE: Don't use mouse selection anymore -- just use selection // to mark player //map.map( mapX, mapY ).m_selected = true; } else { sprintf( buff, "V %d %d x y %d %d NO TILE", view_x, view_y, mouse_x, mouse_y ); } map.map( player->m_x, player->m_y ).m_selected = true; // Mouse button 2 -- drag if (mouse_b & 0x2) { if (!dragging) { dragging = true; drag_x = mouse_x2; drag_y = mouse_y2; view_drag_x = view_x; view_drag_y = view_y; } else { int dx = mouse_x2 - drag_x; int dy = mouse_y2 - drag_y; view_x = view_drag_x + dx; view_y = view_drag_y + dy; } } else { dragging = false; } // button 1 -- use tool (or walk) if (mouse_b & 0x1) { switch( currTool) { case Tool_WALK: { MapCell &cell = map.map(player->m_x, player->m_y ); px = cell.sx + 4; py = cell.sy + 10; if ((px < mouse_x2) && (py < mouse_y2 )) { player->walk_x = -1; player->walk_y = 0; } else if ((px > mouse_x2) && (py > mouse_y2 )) { player->walk_x = 1; player->walk_y = 0; } else if ((px > mouse_x2) && (py < mouse_y2 )) { player->walk_x = 0; player->walk_y = -1; } else if ((px < mouse_x2) && (py > mouse_y2 )) { player->walk_x = 0; player->walk_y = 1; } } break; } } else { switch( currTool ) { case Tool_WALK: if (last_b & 0x01) { player->walk_x = 0; player->walk_y = 0; } break; } } last_b = mouse_b; // ==== draw ===== rectfill( lobuf, 0, 0, 320, 240, makecol( 135, 171, 189 ) ); //map.draw( lobuf, 10, 30 ); map.draw( lobuf, view_x, view_y, gameObjs ); // draw bubbles int bx = 160 - (bubbles.size() * 12); char buf[10]; for (int i=0; i < bubbles.size(); i++) { TileMap *b = bubbles[i]; draw_sprite( lobuf, b->bub_bmp, bx, 215 - (int)(sin(b->bub_age * M_PI)*3) ); sprintf( buf,"%d", i+1 ); textout_centre_ex( lobuf, font, buf, bx + 13, 231, makecol( 0x44, 0x66, 0x77 ), -1); textout_centre_ex( lobuf, font, buf, bx + 12, 230, makecol( 0xff, 0xff, 0xff ), -1); bx += 24; } //DBG draw player //masked_stretch_blit( playerBmp, lobuf, 0, 0, playerBmp->w, playerBmp->h, // 10, 20, playerBmp->w * 4, playerBmp->h * 4 ); // scale buffer to screen stretch_blit( dbgShowSelects?map.m_selectMap:lobuf, backbuf, 0, 0, lobuf->w, lobuf->h, 0, 0, SCREEN_W, SCREEN_H ); // Draw text and stuff at full res //masked_blit( bubbles[0]->bub_bmp, backbuf, 0, 0, 50, 20, // bubbles[0]->bub_bmp->w, bubbles[0]->bub_bmp->h ); //textout( backbuf, font, buff, 10, 10, makecol( 0xff, 0xff, 0xff ) ); drawing_mode( DRAW_MODE_TRANS, NULL, 0, 0 ); set_trans_blender( 0, 0, 0, 128 ); rectfill( backbuf, 0, 7, 640, 75, makecol( 0xff, 0xff, 0xff ) ); solid_mode(); hline( backbuf, 0, 7, 640, makecol( 0, 0, 0x77 ) ); hline( backbuf, 0, 75, 640, makecol( 0, 0, 0x77 ) ); // player icon masked_stretch_blit( playerBmp, backbuf, 0, 0, playerBmp->w, playerBmp->h, 10, 10, playerBmp->w * 4, playerBmp->h * 4 ); //party icons for (int i=0; i < npcs.size(); i++) { BITMAP *npcBmp = npcs[i]->m_bmp; masked_stretch_blit( npcBmp, backbuf, 0, 0, npcBmp->w, npcBmp->h, 70 + 45*i, 10, npcBmp->w * 4, npcBmp->h * 4 ); } if (strlen(messageText)) { float t = (float)messageTime / MSG_TIME; //textout_centre_ex( backbuf, font, messageText, 322, 62, makecol( 0x44, 0x66, 0x77 ), -1 ); textout_centre_ex( backbuf, font, messageText, 320, 60, makecol( lerp( t, 0x00, 0xcc ), lerp( t, 0x00, 0xcc ), lerp( t, 0x00, 0xcc ) ), -1 ); //makecol( 0x44, 0x66, 0x77 ), //makecol( 0xff, 0xff, 0xff ), -1 ); } // flip screen vsync(); acquire_screen(); blit( backbuf, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H ); release_screen(); yield_timeslice(); } return 0; }