Drawing a sprite....

#1turtleman64Posted 7/23/2012 11:08:20 AM
I seem to be at a loss here. The ingame manual doesn't seem to explain much in this department and the game samples given do little in the context of comments and such. I can program in modern languages but ironically enough, this old archaic language seems very cryptic to me, especially when I try to read other peoples code.

What are the exact commands for loading then drawing a sprite onto the screen? I can't figure it out at all! :(
#2GRNKRBYPosted 7/23/2012 11:35:01 AM
I need help with his too. There's that one sample program where you can draw over the backgrounds and sprites, but, when it prompts you to save, there's an always an error message for me and the program closes. Just not entirely sure if I'm naming the characters correctly, and not sure how to load any of the sample sprites into a program.
#3N64MarioPosted 7/23/2012 12:00:59 PM
the CHRED program lets you draw your own sprites for your games.

Be sure that the file name you save is 8 characters or less.
---
N-Mario
#4turtleman64(Topic Creator)Posted 7/23/2012 1:45:51 PM
That's not what I'm talking about. Maybe draw was the wrong word so lemme rephrase this.
How do I render sprites onto the screen?
#5N64MarioPosted 7/23/2012 2:05:51 PM
Yea, Draw was definitely the wrong word to use.

Anyway, the best thing you can do now is look over the help document in the game for your answer. It basically gives you the details of the existing sprite set, as well as a glossary of all the terms, what they mean, and what they do. . ;)
---
N-Mario
#6turtleman64(Topic Creator)Posted 7/23/2012 2:21:46 PM
As I said in the first post, the ingame documentation is of little help in explaining some of the built-in functions for the program.
#7N64MarioPosted 7/23/2012 5:17:07 PM
SPANIM 0, 2, 10, 0

Adding this line in a blank script seems to place a character sprite in the upper left corner of my screen.

You might want to mess with the numbers there until you're satisfied with the animation results.
---
N-Mario
#8turtleman64(Topic Creator)Posted 7/24/2012 9:13:31 AM
I figured it out. You load a sprite into memory using SPSET, and then you position it using SPOFS.
#9DClaxPosted 7/24/2012 8:14:12 PM
turtleman64 posted...
I figured it out. You load a sprite into memory using SPSET, and then you position it using SPOFS.


i don't get it. where do you use SPSET? do you use that while in CHRED or when writing a program? and if its when writing a program do you do that when you are editing it or when you are running?
---
3DS FC: 1676-3725-4140 (msg me if you add me)
#10turtleman64(Topic Creator)Posted 7/25/2012 10:25:46 AM
To render a sprite on the screen first you use SPSET to inititalize the sprite. The same way you would declare and initialize a regular variable like an integer or string or whatnot, you do the same using SPSET. You then use SPOFS(sprite offset, I believe is what it stands for) in your gameloop to manipulate where and how you'd like to render the sprite on screen.

for example if I wanted to render the included skeleton sprite on the top screen at 100x, 100y, I'd do this. (using ' as comment markers)

'begin variable declarations and other initializations
ACLS 'Clears the console screen at the beginning of run-time.
VISIBLE 0,1,1,1,1,1 'Makes the console layer invisible. Refer to the manual for more info on the parameters
SPAGE 0 'Sets any sprite rendering to the top screen.
SPSET 0,130,5,0,0,0,16,16 'Here I will explain the parameters myself in order or appearance in a quotebox.
'0 is the sprite ID. Every sprite you use will have a unique spriteID so that whenever you'd like to manipulate anything about said sprite, this will be the identifier you use.
'130 is the number from the built-in sprite set (SPU2) that the foward facing skeleton character resides on.
'5 this is the pallet number. Should be self-explanatory, but it you've never tried your hand at rom-hacking or anything involving limited colors, the pallet is the chosen color set for the sprite. 5 will produce a blue skeleton character.
'0 horizontal rotation. 0 for none, and 1 to flip the sprite image horizontally. Think of it as mor of mirroring the sprite rather than rotation.
'0 vertical rotation. Same as above, except vertical
'0 Layer. Lower the number, higher the layer.
'16 Width, How wide the sprite is. The skull sprite, by default, s 16x16 pixels. Any less and it wouldn't show the whole sprite. Any more and it's wasted space for this particular sprite.
'16 Height, same as above.


POSX = 100 'Variable for X position of sprite. Could be named anything you want, it's just an integer.
POSY = 100 'Same as above, Except as Y position.
'end variable declarations

'Begin Game Loop 'Start of the Update phase, this is where the bulk of your gameplay code should go.
@UPDATE
'anything involving input and changes to sprite variables goes here
GOTO @RENDER 'Finishes the update phase and goes to render the sprites using the newly updated sprite variables.

@RENDER 'Start the Rendering phase, this is where you will put all of your direct sprite manipulation commands in
SPOFS 0, POSX, POSY, 1 ' SpriteID, X position, Y position, and interpolation time (measured in 1/60th of a second, the desired time between the previous state and the new state. By default, go with 1 unless you're doing some advanced tweeking)
GOTO @UPDATE 'Finishes rendering stage and goes back to the update phase of the gameloop
'End Game Loop

There are other commands that can go in the render phase such as SPANIM and SPANGLE and SPSCALE, but What I've put here is the most basic form of a gameloop rendering one non-moving sprite onto the screen. It's basically the gameform of a 'HelloWorld' program. Hope This helped!