SPRITES
Moderator: Stef
SPRITES
Hello again!
I've been messing around with SGDK now for a few hours now and so far Im really impressed. Already have a sprite moving over a surface.
In c64 assembler this took like a week
I was wondering if there is a way load bmp into a sprite? So far I have only managed to do the sprites "by coding hand" like writing in the picture in assembler. I can see from examples that this is possible, but I cannot get any of the examples to work as the code and tutorials has changed to much.
Please help
I was also wondering were the limitations in using C instead of assembler kicks in. Would you be able to make a platform game with this C library?
How fast is it compared to assembler etc etc, suppose I make a game and run into a dead end, because im using C. That woudnt be fun.
I've been messing around with SGDK now for a few hours now and so far Im really impressed. Already have a sprite moving over a surface.
In c64 assembler this took like a week
I was wondering if there is a way load bmp into a sprite? So far I have only managed to do the sprites "by coding hand" like writing in the picture in assembler. I can see from examples that this is possible, but I cannot get any of the examples to work as the code and tutorials has changed to much.
Please help
I was also wondering were the limitations in using C instead of assembler kicks in. Would you be able to make a platform game with this C library?
How fast is it compared to assembler etc etc, suppose I make a game and run into a dead end, because im using C. That woudnt be fun.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: SPRITES
Hi Staffan,
Thanks for the nice words about SGDK
Of course you can use bmp or png to load up your sprite image As tutorials are quite outdated i definitely recommend you to look over the included 'sprite' sample which is a very simple example about how to deal with that.
Basically you should have your resources in a 'res' folder and a .res file declaring them.
Supported resource and format of .res file is described in the bin/rescomp.txt file.
C code is enough for a platform like game, of course you can do more with pure assembly but on MD you can already achieve a lot just with plain C.
This is 2 examples of game wrote in pure C with SGDK :
https://www.youtube.com/watch?v=nfbo0jQEK80
https://www.youtube.com/watch?v=8jDmft2H_Po
And these examples are quite outdated, today SGDK is faster because some methods has been optimized and also because of the new GCC introduced since the last version (1.30) =)
Thanks for the nice words about SGDK
Of course you can use bmp or png to load up your sprite image As tutorials are quite outdated i definitely recommend you to look over the included 'sprite' sample which is a very simple example about how to deal with that.
Basically you should have your resources in a 'res' folder and a .res file declaring them.
Supported resource and format of .res file is described in the bin/rescomp.txt file.
C code is enough for a platform like game, of course you can do more with pure assembly but on MD you can already achieve a lot just with plain C.
This is 2 examples of game wrote in pure C with SGDK :
https://www.youtube.com/watch?v=nfbo0jQEK80
https://www.youtube.com/watch?v=8jDmft2H_Po
And these examples are quite outdated, today SGDK is faster because some methods has been optimized and also because of the new GCC introduced since the last version (1.30) =)
Re: SPRITES
A res file! That explains why the bitmap name wasnt mentioned in the source code of the example!
The examples looks awesome! No limitations I guess. 3D I can live without...
The examples looks awesome! No limitations I guess. 3D I can live without...
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: SPRITES
Hehe, yeah the .res file is used to declare any external resource
And the demo games examples from djcc are really impressive for 100% C code, of course he's a good coder and he cleverly designed the code, still it show it's possible to do full and good games with 100% C code
About 3D, well SGDK has some methods if you want to play with (flat rendering only) :p
And the demo games examples from djcc are really impressive for 100% C code, of course he's a good coder and he cleverly designed the code, still it show it's possible to do full and good games with 100% C code
About 3D, well SGDK has some methods if you want to play with (flat rendering only) :p
Re: SPRITES
You probably can't really do really fancy effects and complex games such as Sonic or Aladdin, but definitely simpler games could be done. In fact, Sonic Spinball was written completely in C, and I assume its very old compiler, not sure of GCC or something else, but probably not even nearly as good as today's compilers! Definitely for some poking around or unprofessional work, working with pure C wont be a problem, and you can work around the slower nature of C code compared to assembly with just designing better algorithms, that will be faster and more RAM efficient. Though, asm is also very useful thing to know when/if you want to make more complex games, you can pull of some really impressive optimization tricks using it, something that I doubt will ever be possible with just a C compiler.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: SPRITES
I would have said that with the previous GCC version but with the last one, the performance start to be really interesting so i think you can even do complex game logic as soon the code and algorithm are good
Re: SPRITES
Aha so there was a C compiler back in thoose days. I thought that this community had written the compiler all by themself.
Still impressive do!
*********************************************************************************
I tried to compile this:
VDP_loadTileData( &LoloFront, 1, 1, 0);
With the resfile locking like this:
SPRITE LoloFront "sprite/lolo.bmp" 1 1 FAST 5
it says that &LoloFront is undeclared. The sprite example looks to old with completly different functions. Please help me load my sprite
Please spritemind people!
Still impressive do!
*********************************************************************************
I tried to compile this:
VDP_loadTileData( &LoloFront, 1, 1, 0);
With the resfile locking like this:
SPRITE LoloFront "sprite/lolo.bmp" 1 1 FAST 5
it says that &LoloFront is undeclared. The sprite example looks to old with completly different functions. Please help me load my sprite
Please spritemind people!
Re: SPRITES
Do you have an include for "name_of_res_file.h"? Rescomp generates that header based on the .res.
Re: SPRITES
This is the way I usually declare a sprite in the .res file;
With this just make sure that the image you're using is indexed for 16 color palette (I usually convert it in gimp)
and that its in the same directory as the res file
(or use a slash if you have it in a folder next to the .res file which I usually keep in the res folder)
Then in the actual code you can make a sprite array and use SPR_addSprite() ;
And yeah like grind says remember to include the .h file
sprite.h
Code: Select all
SPRITE bubble_sprite "bubble1.png" 1 1 -1 1
and that its in the same directory as the res file
(or use a slash if you have it in a folder next to the .res file which I usually keep in the res folder)
Then in the actual code you can make a sprite array and use SPR_addSprite() ;
Code: Select all
Sprite *sprites[10]; //10 sprites
sprites[0] = SPR_addSprite(&bubble_sprite, posx, posy, TILE_ATTR(PAL0, TRUE, FALSE, 0));
Code: Select all
#include <genesis.h>
#include "sprite.h"
...
Code: Select all
#ifndef _RES_SPRITE_H_
#define _RES_SPRITE_H_
extern const SpriteDefinition bubble_sprite;
#endif // _RES_SPRITE_H_
Re: SPRITES
Thank you!
It almost worked...
He now loads image but with the wrong offset.
I now see that the tutorial is still worth to look at. I used VDP functions I saw on some other site even for sprite and not just for background,
but now I use SDR for sprite.
It almost worked...
He now loads image but with the wrong offset.
I now see that the tutorial is still worth to look at. I used VDP functions I saw on some other site even for sprite and not just for background,
but now I use SDR for sprite.
Re: SPRITES
Would appreciate this. The sprite loads in the middle of sprite and in wrong order... I think I do exactly as the sprite tutorial now.
Its a 24*24 pixel bitmap.
SPRITE LoloFront "sprite/lolo.bmp" 3 3 -1 1
---------------------------------
SPR_init(16, 256, 256);
sprites[0] = SPR_addSprite(&LoloFront, 0, 0, TILE_ATTR(PAL1, FALSE, FALSE, 0));
// VDP process done, we can re enable interrupts
SYS_enableInts();
Its a 24*24 pixel bitmap.
SPRITE LoloFront "sprite/lolo.bmp" 3 3 -1 1
---------------------------------
SPR_init(16, 256, 256);
sprites[0] = SPR_addSprite(&LoloFront, 0, 0, TILE_ATTR(PAL1, FALSE, FALSE, 0));
// VDP process done, we can re enable interrupts
SYS_enableInts();
Re: SPRITES
There's documentation that you can refer to in older SGDK versions, you can look it up with the forum search in the top right
When you find the doc folder, open the html folder and click on the index file and then go through the lists like the file list
Also look for the rescomp.txt file it has better details about the tools and what the numbers in the sprite res file are for
If you're not sure about something like using certain functions you can also look that up in the forum or post and ask about it
When you find the doc folder, open the html folder and click on the index file and then go through the lists like the file list
Also look for the rescomp.txt file it has better details about the tools and what the numbers in the sprite res file are for
If you're not sure about something like using certain functions you can also look that up in the forum or post and ask about it
Re: SPRITES
Thanx,
The documentation works fine, but theres just a list of fuctions and what they do.
Thats good, but its the same information I have in Visual Code itself. As soon as I start typing visualcode suggest a function and I can se a list of all available, so thats pretty good. I can also click "goto definition" where I can se the description of the input variables. I have still find zero information on why he loads the sprite in the wrong order, and skips the first three squares.
The documentation works fine, but theres just a list of fuctions and what they do.
Thats good, but its the same information I have in Visual Code itself. As soon as I start typing visualcode suggest a function and I can se a list of all available, so thats pretty good. I can also click "goto definition" where I can se the description of the input variables. I have still find zero information on why he loads the sprite in the wrong order, and skips the first three squares.
Re: SPRITES
Original sprite:
How he loads it:
I really want to be one of those guys that asks about everything on the forum...but Im stuck here. Ive been checking the sprite tutorial quite alot now. I just had alot of time with this this weekend. This is not the usual me, with two kids Re: SPRITES
Ok, I used a 16 color bitmap whick "kindof" worked. But with png it worked flawlessly