//Draw fight stage
int draw_fight_stage(){ int r, c;
    //Draw basic grass across screen
    for(r = 0; r < num_rows; r++){ // Rows
        for(c = 0; c < num_columns; c++){ 
            block_draw_sp(c, r, &NoGrass_img);
        }
    }
    
    //Spell Rune interface around borders
    //Elec Spell
    for(int i = num_columns-2; i>num_columns-5 ; i--){
        block_draw_sp(i, 0, &Light_img);
    }
    
    //Water Spell
    for(int i = 3; i < 6; i++){
        block_draw_sp(num_columns-1, i, &Water_img);
    }
    
    //Fire Spell
    for(int i = 1; i < 4; i++){
        block_draw_sp(i, 8, &Fire_img);
    }
    
    //Grass Spell
    for(int i = 4; i < 7; i++){
        block_draw_sp(0, i, &Earth_img);
    }
    
    draw_char();
    block_draw(4, 5, ST7735_BLACK);
    block_draw(5, 5, ST7735_BLACK);
    
    int element = random(1, 5); //Random Generation of Enemy
    Serial.print(element);
    if(element == 1){ //Fire Monster
        draw_enemy(&Fmns_img);
    }
    if(element == 2){ //Water Monster
        draw_enemy(&Wmns_img);
    }
    if(element == 3){ //Lightning Monster
        draw_enemy(&Lmns_img);
    }
    if(element == 4){ //Earth Monster
        draw_enemy(&Emns_img);
    }
    
    
    
    return element;}
예제 #2
0
파일: invaders.c 프로젝트: miloh/f1rmware
void ram(void) {
	while(1) {
		if (!screen_intro()){
      setTextColor(0xff,0x00);
      return;
    }
		game.rokets = 3;
		game.level = 1;
		game.score = 0;
		init_game();
		screen_level();
		while (game.rokets>=0) {
			////checkISP();
			lcdFill(0x00);
			check_end();
			move_ufo();
			move_shot();
			move_shots();
			move_player();
			move_enemy();
			draw_score();
			draw_ufo();
			draw_bunker();
			draw_player();
			draw_enemy();
			draw_shots();
			//        draw_status();
			lcdDisplay();
			delayms(12);
		}
		if (!screen_gameover())
      setTextColor(0xff,0x00);
      return;
	}
}
예제 #3
0
int main()
{
	g_level = 0;
	g_nEnemy = 1;	//	敵機数:1
	init();
	draw_map();
	draw_car();
	draw_enemy();
	draw_score();
	g_db.swap();		//	表示バッファ切り替え
	getchar();
	return 0;
}
예제 #4
0
파일: video.c 프로젝트: kyuh/ChingOS
void init_video(void) {
    char * datas = ((char*) PROGRAM_BASE_ADDR);
    datas += 100000;
    datas -= 512;

    assets = (Game_Assets*)datas;

    //color_screen(0x3f);
//    write_string_position(5, "wowowow", 5, 5);
//    write_string_position(5, hu, 5, 15);
//    write_string_position(5, katana, 5, 25);

    draw_bullet(6, 11, 15, 5);
    draw_player(15, 35);
    draw_enemy(0, 15, 55);
    draw_enemy(1, 15, 70);
    /* TODO:  Do any video display initialization you might want to do, such
     *        as clearing the screen, initializing static variable state, etc.
     */
    // Clear Screen - not yet debugged.
    // clearScreen();

    #if 0
    //TEST~nico~~
    #if 0
    write_string_offset(RED, string, 10);
    #endif

    // TEST 2~~nico~~~~
    color_pixel(RED, 50);
    color_pixel(BLUE, 52);
    color_pixel(YELLOW, 54);
    color_pixel(WHITE, 210);
    color_pixel(GREEN, 212);
    color_pixel(CYAN, 214);
    #endif
}
예제 #5
0
int main()
{
	//mciSendString(TEXT("open button57.mp3"), NULL, 0, NULL);
	//mciSendString(TEXT("open s-burst01.mp3"), NULL, 0, NULL);
	//mciSendString(TEXT("open one23.mp3"), NULL, 0, NULL);
	for (;;) {
		bool rc = game();
		g_db.setCursorPos(0, CONS_HT - 1);
		g_db.setColor(COL_GRAY, COL_BLACK);
		//if( rc ) {
		//	g_db.write("!!! GOOD JOB !!!");
		//} else {
			g_db.write("GAME OVER.");
		//}
		g_db.write(" Try Again ? [y/n] ");
		draw_map();
		draw_enemy();
		draw_car();
		draw_score();
		g_db.swap();
		for (;;) {
			if( isKeyPressed('N') )
				return 0;
			if( isKeyPressed('Y') )
				break;
			Sleep(LOOP_INTERVAL);		//	10ミリ秒ウェイト
		}
		g_db.setCursorPos(0, CONS_HT - 1);
		for (int i = 0; i < CONS_WD - 1; ++i) {
			g_db.write(" ");
		}
		g_db.swap();
		g_db.setCursorPos(0, CONS_HT - 1);
		for (int i = 0; i < CONS_WD - 1; ++i) {
			g_db.write(" ");
		}
	}
	return 0;
}
예제 #6
0
bool game()
{
	g_score = 0;
	g_level = 0;
	g_nEnemy = 1;
	init();
	int key = 0;   // 押下されたキー
    int keyDown = 0;   // 押下状態のキー
    bool update = true;
    int iv = 10;
    for (int cnt=1;;++cnt) {
    	if( update ) {
			int nDot = draw_map();
			draw_enemy();
			draw_car();
	        draw_score();
			g_db.swap();
			if( !nDot ) {		//	ドット全消去
				mciSendString(TEXT("play one23.mp3"), NULL, 0, NULL);
				Sleep(1000);
				g_score += g_nEnemy * 1000;
				if( ++g_level > 1 )
					++g_nEnemy;
				init();
				continue;
				//return true;
			}
			if( check_crash() ) {
				mciSendString(TEXT("play s-burst01.mp3"), NULL, 0, NULL);
				return false;
			}
    	}
		Sleep(10);
		update = false;
		if( !keyDown ) {     // キー押下を受け付けていない場合
            if( isKeyPressed(VK_LEFT) ) {
                key = keyDown = VK_LEFT;
            } else if( isKeyPressed(VK_RIGHT) ) {
                key = keyDown = VK_RIGHT;
            } else if( isKeyPressed(VK_UP) ) {
                key = keyDown = VK_UP;
            } else if( isKeyPressed(VK_DOWN) ) {
                key = keyDown = VK_DOWN;
            }
        } else {
            if( !isKeyPressed(keyDown) )// 押されたキーが離された
                keyDown = 0;
        }
        if( cnt % 10 == 0 ) {
        	for (int i = 0; i < (int)g_enemy.size(); ++i) {
		        move_car(g_enemy[i]);
		        change_lane(g_enemy[i]);
        	}
	        update = true;
        }
        accel_decel(key, iv);
        if( cnt % iv == 0 ) {
	        move_car(g_car);
	        change_lane(g_car, key);
	        //move_car(g_car, key);
	        eat_dot();
	        update = true;
	        iv = 10;
        }
	}
}
예제 #7
0
파일: skios.c 프로젝트: ryonagana/skios2
int game_loop(){


    unsigned redraw = 0;

    game_rect t;
    rect_Zero(&t);
    sprite_sheet = gamespr_create("ski1.bmp");

    animation_init();
    init_player();
    start_new_game(0);


    while(!mainloop){

        ALLEGRO_EVENT e;
        ALLEGRO_TIMEOUT timeout;
        int i;

        al_init_timeout(&timeout, 0.06);

        bool  late = al_wait_for_event_until(g_queue, &e, &timeout);





        if(late){
            switch(e.type){
                case ALLEGRO_EVENT_DISPLAY_CLOSE:
                    mainloop = 1;
                    break;

                 case ALLEGRO_EVENT_KEY_UP:
                        player_poll_kbd_up(&e);
                 break;

                 case ALLEGRO_EVENT_KEY_DOWN:
                        player_poll_kbd_dn(&e);
                 break;

                case ALLEGRO_EVENT_TIMER:

                /* main clock updates 1/60ms (60FPS LOCK) */
                    if(e.timer.source == g_timer){
                        particle_list = particles_clean(particle_list, 0);
                        particles_update(particle_list);
                        player_update_screen();
                        player_update(&ski_player, &playfield);



                        for(i = 1; i < MAX_SPRITES; i++){
                           update_enemy(i);
                        }

                        update_enemy_behavior(gobj_list, &playfield);

                        redraw =  1;
                    }

                     /* update for the chronomenter run every 100ms only) */
                    if( e.timer.source == timer_chrono){
                        HUD_UpdateChrono();
                        DMSG("%d", al_get_timer_count(timer_chrono));




                    }

                    break;
            }


            if( redraw == 1 && al_event_queue_is_empty(g_queue)){
                    redraw = 0;
                    al_clear_to_color(WHITE_COLOR);


                    particles_draw(NULL, particle_list);
                    player_draw(ski_player.object->position.x, ski_player.object->position.y );

                    for(i = 1; i < MAX_OBJECTS; i++){
                         int enemy_type = gobj_list[i].type;
                         draw_enemy(enemy_type, i, 0,0, gobj_list[i].position.x, gobj_list[i].position.y, 32,32);

                    }

                    HUD_create_stats_box();
                    al_flip_display();
            }
        }

    }

    HUD_destroy();
    unload_spritesheets();
    window_deinit();
    particle_list = particles_clean(particle_list, PARTICLES_ALL_CLEAN);
    return EXIT_SUCCESS;
}
예제 #8
0
int run()
{

    /* Initialize the random number generator */
    srand(time(NULL));
    bool quit = false;
    printf("running\n");

    if(!init_game())
    {
        exit(2);
    }
head:
    if(!load_data())
    {
        printf("data load error\n");
        exit(2);
    }
    init_common_num();
    apply_background();
    init_player();
    draw_player();
    SDL_Color textColor = { 255, 255, 255 };
    //Update the screen
    if( SDL_Flip( screen ) == -1 )
    {
        return 1;
    }
    //While the user hasn't quit
    while( quit == false )
    {
//		printf("%d\n" , rand()%2);
        wait_frame();
        //While there's an event to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                quit = true;
            }

            if( apear_enemy > ENEMY_NUM)
            {
                complete_level(event);
            }
            else
            {
                if( player.alive == 1)
                {
                    player_input(event);
                }

            }
        }
        if(enemy.alive == 0)
        {
            init_enemy();

        }
        if(enemy.alive == 1)
        {
            enemy_move();
        }

        if(bullet.alive == 1)
        {
            bullet_move();
        }

        if(knock(bullet , enemy)) {
            enemy.image = load_image("data/boom.gif", 1);
            bullet.image = load_image("data/boom.gif", 1);
            //		draw_enemy();
            //		draw_bullet();
            enemy.alive = 0;
            bullet.alive = 0;
            bullet.x = -1000;
            bullet.y = -1000;
            score ++;
            final_score ++;
        }
        if(knock(player , enemy)) {
            enemy.image = load_image("data/boom.gif", 1);
            player.image = load_image("data/boom.gif", 1);
            //		draw_enemy();
            //		draw_bullet();
            player.alive = 0;
            enemy.alive = 0;
            quit = true;
        }
        player_move();
        apply_background();
        draw_enemy();

        if(bullet.alive == 1)
        {
            draw_bullet();
        }
        draw_player();
        if(apear_enemy > ENEMY_NUM)
        {

            char text0[256] = "";
            sprintf(text0, "      LEVEL   %d", GAME_LEVEL);
            message = TTF_RenderText_Solid( font, text0, textColor );
            apply_surface( 20 , 50 ,  message , screen);
            char text1[256] = "PRESS \"n\" TO NEXT LEVEL";
            message = TTF_RenderText_Solid( font, text1, textColor );
            apply_surface( 20 , 150 ,  message , screen);
            char text2[256] = "";
            sprintf(text2, "        SCORE:%d", score);
            message = TTF_RenderText_Solid( font, text2, textColor );
            apply_surface( 20 , 250 ,  message , screen);
            char text3[256] = "";

            if(score ==0 || shoot_time == 0)
            {
                sprintf(text3, "     ACCURATE:%d" , 0);
            }
            else
            {
                sprintf(text3, "     ACCURATE:%.2lf%%",(double)score/shoot_time*100);
            }
            message = TTF_RenderText_Solid( font, text3, textColor );
            apply_surface( 20 , 350 ,  message , screen);

        }



        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }
        if(player.alive == 0) {
            quit = true;
        }
        if(enemy.alive == 0)
        {
            init_enemy();
        }


    }

    char text1[256] = "       GAME  OVER   ";
    message = TTF_RenderText_Solid( font, text1, textColor );
    apply_surface( 20 , 50 ,  message , screen);
    char text2[256] = "";
    sprintf(text2, "       FINAL_SCORE:%d", final_score);
    message = TTF_RenderText_Solid( font, text2, textColor );
    apply_surface( 20 , 150 ,  message , screen);
    char text3[256] = "    PRESS \"r\" TO RESTART";
    message = TTF_RenderText_Solid( font, text3, textColor );
    apply_surface( 20 , 250 ,  message , screen);
    char text4[256] = "    PRESS \"q\" TO EXIT";
    message = TTF_RenderText_Solid( font, text4, textColor );
    apply_surface( 20 , 350 ,  message , screen);
    if( SDL_Flip( screen ) == -1 )
    {
        return 1;
    }

    quit = false;
    while( quit == false )
    {
//		printf("%d\n" , rand()%2);
//		wait_frame();
        //While there's an event to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                quit = true;
            }
            if( event.type == SDL_KEYDOWN ) {
                //Adjust the velocity
                switch( event.key.keysym.sym ) {
                case SDLK_r:
                    goto head;
                    break;
                case SDLK_q:
                    quit = true;
                    break;
                }
            }
        }
    }

    //Close the font that was used
    TTF_CloseFont( font );
    //Quit SDL_ttf
    TTF_Quit();
    //Quit SDL
    SDL_Quit();
}