// Updates all nescessary sprites, images, buttons etc. void update(void) { static _Bool called = false; GDATAPTR game = get_game_data(); update_background(); if(game->gamestarted && game->paused) { paused(score, survival_time, lives); } else if(lives == 0) { gameover(score, survival_time); } else if(game->gamestarted) { if(!called) { //cpSpaceResizeStaticHash(get_global_cpSpace(), 700.0, 4*10); cpSpaceAddCollisionHandler(get_global_cpSpace(), 1, 2, collision_begin, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 2, collision_static_begin, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 1, collision_static_begin, NULL, NULL, NULL, NULL); called = false; } logic(); update_clouds(); cpSpaceStep(get_global_cpSpace(), 1.0f/60.0f); cpSpaceEachBody(get_global_cpSpace(), &update_sprites, NULL); update_ground(); update_lives(); add_element_to_render_queue(NULL, 0, 0, 0, RCOLOR(0, 0, 0, 255), update_score); add_element_to_render_queue(NULL, 290, 0, 0, RCOLOR(0, 0, 0, 255), update_survivaltime); } else if(game->options) { options(); } else if(game->howtoplay) { howtoplay(); } else if(game->highscores) { highscores(); } }
static int mark_for_copy(Word p, int flags ARG_LD) { Word start = p; int walk_ref = FALSE; Word buf[1024]; segstack stack; initSegStack(&stack, sizeof(Word), sizeof(buf), buf); for(;;) { switch(tag(*p)) { case TAG_ATTVAR: { if ( flags & COPY_ATTRS ) { if ( !pushForMark(&stack, p, walk_ref) ) { clearSegStack(&stack); return MEMORY_OVERFLOW; } walk_ref = TRUE; p = valPAttVar(*p); continue; } /*FALLTHROUGH*/ } case TAG_VAR: { if ( virgin(*p) ) set_visited(*p); else if ( visited_once(*p) ) set_shared(*p); break; } case TAG_REFERENCE: { if ( !pushForMark(&stack, p, walk_ref) ) { clearSegStack(&stack); return MEMORY_OVERFLOW; } walk_ref = TRUE; deRef(p); continue; } case TAG_COMPOUND: { Functor t = valueTerm(*p); int arity = arityFunctor(t->definition); if ( virgin(t->definition) ) { set_visited(t->definition); } else { if ( visited_once(t->definition) ) set_shared(t->definition); break; } if ( arity >= 1 ) { if ( !pushForMark(&stack, p, walk_ref) ) { clearSegStack(&stack); return MEMORY_OVERFLOW; } walk_ref = FALSE; p = &t->arguments[arity-1]; /* last argument */ continue; } } } if ( p == start ) { clearSegStack(&stack); return TRUE; } while ( walk_ref ) { popForMark(&stack, &p, &walk_ref); if ( isAttVar(*p) ) { Word ap = valPAttVar(*p); unshare_attvar(ap PASS_LD); } if ( p == start ) { clearSegStack(&stack); return TRUE; } } p--; if ( tagex(*p) == (TAG_ATOM|STG_GLOBAL) ) { popForMark(&stack, &p, &walk_ref); update_ground(p PASS_LD); } } }