Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.49 KB | None | 0 0
  1. //System
  2. #include <gb/gb.h>
  3. #include <stdio.h>
  4.  
  5. //Sprites
  6. #include "sprites/SmileSprites.c"
  7.  
  8. //It's the main function. Program starts here, ends when the cart is removed, emulator is closed, etc.
  9. void main () {
  10.  
  11.     //Creates an unsigned 8-bit integer using given name, starting at 0.
  12.     //This is used for animation starting at the game loop, `while(1){}`
  13.     UINT8 currentSpriteIndex = 0;
  14.  
  15.     //Sets the sprite data.
  16.     //0 is the index of which tile it is, 2 is how many there are, and Smiler is the name of the sprite.
  17.     //See SmileSprites.c/.h
  18.     set_sprite_data(0, 2, Smiler);
  19.     //Sets the initial position of the sprite.
  20.     move_sprite(0, 88, 78);
  21.     //Show all sprites.
  22.     SHOW_SPRITES;
  23.  
  24.     //Game loop stuff. Right now this handles sprite animation and scrolling, which happens every 1000 milliseconds.
  25.     //Every 1000 ms, the sprite index is set to 1, then 0. currentSpriteIndex holds the current frame of animation.
  26.     while(1) {
  27.  
  28.         if(currentSpriteIndex==0) {
  29.             currentSpriteIndex = 1;         //currentSpriteIndex = 1 : :)
  30.  
  31.         }
  32.         else {
  33.             currentSpriteIndex = 0;         //currentSpriteIndex = 0 : :|
  34.         }
  35.         //Sets the sprite data to the currentSpriteIndex, causing the face of the sprite to change from :| to :). Cute if you ask me <3
  36.         set_sprite_tile(0, currentSpriteIndex);
  37.         delay(1000);
  38.         //Scrolls the sprite by 10 pixels every 1000 ms.
  39.         scroll_sprite(0, 10, 0);
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement