? Sprites 101 (for Beginners) ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Contest results!

Sprites 101 (for Beginners)

So, you want to create programs and games! Well an essential part of those are little (sometimes big) things called sprites, and I'm going to teach you everything you need to know to start controlling sprites. (WARNING: THINGS STATED HERE ARE IN LAYMAN'S TERMS, A LOT) THERE IS A TL;DR AT THE END YOU LAZY PERSON

PART 1: WHAT THE HECK IS A SPRITE?!

I'm glad you asked title, a sprite is a 2-D image that is used in coding. Sprites can be used for many different purposes not covered in this tutorial. But mostly, sprites are used for things like players, enemies and objects that can interact with other things (Ex: player pushing a boulder or pressing a button).

PART 2: HOW DO I SPRITE!?

It's actually very simple in SmileBASIC, just go into EDIT mode and type this EXACTLY how you see it: ACLS SPSET 0,17 Wow, your very first sprite! Now let's break down the code. ACLS is used to clear EVERYTHING (Sprites, text, background tiles, etc.) and it is optional, but I reccomend that you put it at the start of all your programs to clear everything left by other programs. SPSET Is the command that "summons" the sprite the zero is the management number, that number is used to control that sprite and it is decided here it can be anywhere from 0 all the way to 511! You should remember the management number of your player, because it is used to control that sprite in all the other sprite commands. Now, the 17 is the sprite displayed. To find all the sprites and their corresponding sprite number open the Smile tool and go to the SPDEF tab.

PART 3: HOW DO I MOVE FISHY?!

This is kind-of complicated and I won't be able to break down ALL of the code, but open EDIT mode and type this in: ACLS SPSET 0,17 WHILE 1 STICK OUT SX, SY X=X+SX Y=Y-SY SPOFS 0,X,Y VSYNC 1 WEND Use the circle pad to move the fish, wow you're on your way to understanding sprites! Now I'm going to try to break down the code and simplify it. WHILE 1 AND WEND are very similar to @LOOP and GOTO @LOOP, but I'm not going to explain it in this tutorial because this tutorial is about sprites you diploid. Okay, now to the juicy bits. STICK OUT just gets data from the circle pad's horizontal (left and right) and vertical (up and down) positions. Now, I'll explain the rest a bit faster to save time, the vertical position of the sprite is represented by Y and the horizontal X. The circle pad's are SY and SX, so when you move the Circle pad right, SX becomes greater and it adds to X and moves the sprite right with SPOFS. SPOFS is used for instantly moving a sprite to the x and y positions specified. 0 is the management number stated earlier in the tutorial, change it to another number to move other sprites. You HAVE to have previously "summoned" the sprite using SPSET before using any other command or else you'll get an error. X and Y are the X and Y coordinates that the sprite moves to. VSYNC 1 just creates some delay so everything doesn't happen instantly and your fish doesn't go flying offscreen.

TL;DR

Creating sprite: ACLS SPSET 0,17 Moving sprite: ACLS SPSET 0,17 WHILE 1 STICK OUT SX, SY X=X+SX Y=Y-SY SPOFS 0,X,Y VSYNC 1 WEND Thank you for reading this tutorial, if you want to know more about sprites leave a suggestion in the comments and I'll try to reply!
Author
UltraPhoenix4
Updated
Rating
8 votes
Categories
Keywords
  • sprites
  • characters
  • sprite
  • tutorial
  • beginner
21 Comment(s) Super_Defaultio Super_Defaultio Video Games I like to play video games! Hobbies Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Make a BG 101... or an MML 127 *get it* *cough* ToadIsTheBest ToadIsTheBest Avatar Taboo I didn't change my avatar for 180 days Website Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength nah don't get it joelable joelable First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself Video Games I like to play video games! Hobbies
this tutorial is about sprites you diploid
why call people "having two complete sets of chromosomes"
UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website Because it sounds like an insult but isn't really. UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website you diploid snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself might as well use clod UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website Also clod IS an insult
Lacks Lacks More of these, please! UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website What should it be about? (Advanced sprites, simple BG, or something else?) Lacks Lacks Advanced sprite usage, like linking, collision, animation etc. Actually you could do damn near any function in layman's terms and I would find it very useful. I wish there was more tutorials on this program. It would cut down (theoretically) on all the "how do I save?" "How do I link the sword to my sprite" threads I see every so often. UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website They could be cut down by just linking them to the resource and then having an admin delete the thread. Lacks Lacks Yeah, but the resource list isn't designed for someone with no clue about code. And that attitude doesn't breed a strong community. ElzoBro ElzoBro First Day Joined on the very first day of SmileBASIC Source Website Video Games I like to play video games! Hobbies Drawing I like to draw! Hobbies I need Simple BG, and then Sprite Collision please. UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website Then I guess I'll write Sprite 303 later Minxrod Minxrod Summer 2016 Contest Participant I participated in the SmileBASIC Source Summer 2016 Contest! Programming Contest Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Pokemon Is Awesome! I love Pokemon! Express Yourself Management numbers are from 0 to 511, not 0 to 999! Otherwise, it seems to be a pretty good tutorial :) Maybe add SPANIM, SPDEF? UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website Thanks! I fixed the error. I'm going to wait a bit and maybe make a part 2 out of all the questions. Unclesporky Unclesporky 0 to 511, not 512. :) There are 512 entries for sprites, but since 0 counts as the first entry, management numbers end at 511. UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website *Facepalm* 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest Second Year My account is over 2 years old Website it's not ALWAYS 0-511 in XSCREEN modes that use the top and bottom screen (except 4), you can have 512 TOTAL. for example, XSCREEN 3 gives the top screen 512 sprites (0-511), but the bottom screen can't use ANY! you can do XSCREEN 3,75 (for example), to give the top screen 75 sprites (0-74) , and the bottom screen 512 minus 75 (437) sprites (0-436). UltraPhoenix4 UltraPhoenix4 First Year My account is over 1 year old Website Bees Hidden Easter Eggs Avatar Taboo I didn't change my avatar for 180 days Website Well if somebody needs this tutorial they probably don't need to use XSCREEN yet. But good point.