int main(int argc, char **argv) { d_init_custom("AutoKorg", WINDOW_WIDTH, WINDOW_HEIGHT, 0, "robot", NULL); //Calling an initiating function. Said function creates a window //with resolution 800x600, that's now full-screen and with the title AutoKorg. DARNIT_FONT *kgfont = d_font_load("KGRayofSunshine.ttf", 60, 256, 256); //We create a font handle. DARNIT_TEXT_SURFACE *papper = d_text_surface_new(kgfont, 100 , 800, 10, 0); //Here we create a handle to a text surface, using the font previously handled. /*pthread_t threads[1]; hello = pthread_create(&threads[0], NULL, musikka, (void *) NULL);*/ d_cursor_show(1); //Call a funciton which shows the cursor in the window. initiate_buttons(); initiate_serial_port(); for(;;) { //Program loop. d_render_begin(); //Call to start rendering. d_render_blend_enable(); //Enable blend, a call to a function apparently needed. if(state < DISCO){ d_render_tint(255,255,255,255); } else { d_render_tint(rand() & 0xF0, rand() & 0xF0, rand() & 0xF0, 255); } //Another call to a needed function. Don't question the libdarnit. //d_text_surface_string_append(papper, svar); do_stuff(papper); //Call to a function which does stuff. draw_interface(); //Draws us some graphics. d_render_end(); //Call to a function which you do at the stop of rendering. d_loop(); //Call to a function that is to be called inbetween frames. d_text_surface_reset(papper); //Lastly we clear the textsurface. } return 0; //End of show. }
void run() { mk_lines(); const int LINE_JUMP = 3; const int NR_LINES_TOT = lines_.size(); const int MAX_NR_LINES_ON_SCR = SCREEN_H - 2; int top_nr = 0; int btm_nr = min(top_nr + MAX_NR_LINES_ON_SCR - 1, NR_LINES_TOT - 1); while (true) { render::clear_screen(); draw_interface(); int y_pos = 1; for (int i = top_nr; i <= btm_nr; ++i) { const Str_and_clr& line = lines_[i]; render::draw_text(line.str , Panel::screen, Pos(0, y_pos++), line.clr); } render::update_screen(); const Key_data& d = input::get_input(); if (d.key == '2' || d.sdl_key == SDLK_DOWN || d.key == 'j') { top_nr += LINE_JUMP; if (NR_LINES_TOT <= MAX_NR_LINES_ON_SCR) { top_nr = 0; } else { top_nr = min(NR_LINES_TOT - MAX_NR_LINES_ON_SCR, top_nr); } } else if (d.key == '8' || d.sdl_key == SDLK_UP || d.key == 'k') { top_nr = max(0, top_nr - LINE_JUMP); } else if (d.sdl_key == SDLK_SPACE || d.sdl_key == SDLK_ESCAPE) { break; } btm_nr = min(top_nr + MAX_NR_LINES_ON_SCR - 1, NR_LINES_TOT - 1); } render::draw_map_and_interface(); }
//Draw Walking mode map void draw_Map(Coords *cc){ int r, c, i; //Draw Long Grass and Short Grass for(r = 0; r < num_rows; r++){ // Rows for(c = 0; c < num_columns; c++){ //Columns if((cc->blockmap[r][c]) == 0){ block_draw_sp(c, r, &Grass_img); } else { block_draw_sp(c, r, &NoGrass_img); } } } //Draw Crystals at their locations if not already picked up for(i = 0; i < crystal_num; i++){ if(cc->blockmap[cc->crystals[i][0]][cc->crystals[i][1]] == 0){ block_draw_sp(cc->crystals[i][1], cc->crystals[i][0], &Items_img); } else { //Do nothing Grass is already there } } draw_interface(cc);}
int main(int argc, char **argv) { lattice_neighbors=square_lattice_neighbors; lattice_dx=square_lattice_dx; lattice_dy=square_lattice_dy; gmp_randinit_mt(state); gmp_randseed_ui(state, time(NULL)); mpf_init2(rop,256); // wang_landau(5,25,1.0,20,0.8,5,1.5, 0.05, 30); // return 0; double T=2.269185; double step=0.01; int M=50; int N=50; int steps = 100; long measures=10000; double p=1.0; char *method=""; int flags, opt; int nsecs, tfnd; while ((opt = getopt(argc, argv, "M:N:T:S:s:p:m:a:L:")) != -1) { switch (opt) { case 'M': M=atoi(optarg); break; case 'N': N=atoi(optarg); break; case 'T': T = atof(optarg); break; case 'S': step = atof(optarg); break; case 's': steps = atoi(optarg); break; case 'p': p = atof(optarg); break; case 'm': measures=atol(optarg); break; case 'a': method=optarg; break; case 'L': if ((strlen(optarg)==6) && (strcmp("triang",optarg)==0)) { lattice_neighbors=triangular_lattice_neighbors; lattice_dx=triangular_lattice_dx; lattice_dy=triangular_lattice_dy; } break; default: /* '?' */ fprintf(stderr, "Usage: %s [-M xsize] [-N ysize] [-T temperature] [-S temperature step] [-s number of steps] [-p non-empty probability] [-m measures] [-a algorithm:metropolis|wolf|interface|interface_cluster] [-L lattice:square|triang] \n", argv[0]); exit(EXIT_FAILURE); } } // printf("M:[\n"); if ((strlen(method)==4) && (strcmp("wolf",method)==0)) for (int i=0;i<steps;i++) { T=T+step; // printf("Temperature: %lf \n",T); measure_susceptibility_cluster(M,N, init_table_with_p(M,N,p),1/T,measures); // printf("\n"); } else if ((strlen(method)==10) && (strcmp("metropolis",method)==0)) for (int i=0;i<steps;i++) { T=T+step; printf("Temperature: %lf \n",T); measure_susceptibility(M,N, init_table_with_p(M,N,p),1/T,measures); printf("\n"); } else if ((strlen(method)==9) && (strcmp("interface",method)==0)) draw_interface(M,N,allocate_2d_rectangle(M,N),1/T); else generate_interfaces(M,N,allocate_2d_rectangle(M,N),1/T,measures); // printf("[%lf,%lf] ", T,M); // printf("]\n"); // print_Ul(T,step,steps, measures, size,4*size); // print_Ul(T,step,steps, measures, 2*size,3*size); mpf_clear(rop); return 0; }