Jo Engine Forum

Sega Saturn Development => Share your code => Topic started by: SaturnTeam on July 06, 2018, 12:39:32 am

Title: Ship shadow for shooter demo
Post by: SaturnTeam on July 06, 2018, 12:39:32 am
I wanted to share how to set up the shadow for the main ship in the shooter demo. You'll go under draw_ship in your main C file and enter in the following code under the code that's already there:

Code: [Select]
    // SHIP SHADOW
    jo_sprite_enable_shadow_filter();
    jo_sprite_change_sprite_scale(-2.5);
    if (ship.move == RIGHT)
        jo_sprite_enable_horizontal_flip();
    jo_sprite_draw3D(ship.reverse_animation ? jo_get_anim_sprite_reverse(ship.anim_id) : jo_get_anim_sprite(ship.anim_id), ship.x +5, ship.y -25, 800);
    if (ship.move == RIGHT)
        jo_sprite_disable_horizontal_flip();
    jo_sprite_restore_sprite_scale();
    jo_sprite_disable_shadow_filter();

So I've set the trailing shadow scale to 2.5x less than the actual ship size, in order to present the appearance of distance. At the ship's coordinates (ship.x and ship.y), I've shifted the shadow so it is visible, due to not being directly underneath the ship. You'll have to change the numbers based on your specific game. The Z coordinate of 800 is lower than the coordinate for the ship. This technique can be applied to other craft, too.