REQ: More flexibility

If you have a great idea for the program, post it here!

REQ: More flexibility

Postby Leon » August 6th, 2011, 5:56 pm

While trying to ask for help, I found my own solution (which is often the case ;-)
But one thing remains a problem with the sprites:

I add a new sprite of 8x8 pix and want to create three frames in that sprite. So I import a sprite sheet. The problem with that is, that the sprite needs to be at least 16x16 because the option for 8x8 doesn't exist. You can manually change the values but it still loads 16x16.

If I want to add frames manually (add frame, select it and load from file), it always loads the new image in frame 0 and deletes all others.

So the request is either to let the user fill in his/her own values and work with those or display all possible values in the drop down list.
Leon
 
Posts: 13
Joined: July 11th, 2011, 7:11 pm

Re: REQ: More flexibility

Postby Foxi4 » August 7th, 2011, 1:26 am

-snip-

EDIT: Wait, 8x8 should be entirely possible... that's... weird. Well, you can spawn the sprite manually using PA_CreateSprite, I guess ^^;
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1114
Joined: December 31st, 2010, 3:25 am

Re: REQ: More flexibility

Postby Leon » August 7th, 2011, 3:23 pm

Yeah, well.... there's a problem with that. I need to create up to 150 different instances. Creating them all with PA_CreateSprite will give me memory problems. Then PA_CloneSprite is suggested but that doesn't work either. You can clone a sprite 150 times but you can't keep track of the instance since it's a clone and they all get the same ID. Changing it's image changes them all at the same time.

I'm trying to find a way to be able to create 150 squares of 8x8 and give them one of three states. But all independently and being able to tell which square has which image. The changing of the sprite and the tracking isn't the problem. It's the quantity that causes issues.

Even adding them through DSGM in design mode doesn't work. That is, I can add them on screen but I wouldn't know how to address them individually from code. Besides, I wouldn't know if that gives memory errors as well.
Leon
 
Posts: 13
Joined: July 11th, 2011, 7:11 pm

Re: REQ: More flexibility

Postby JanMulder » August 7th, 2011, 3:31 pm

A background is built by 8x8 tiles.
I think you can change them with PA_SetMapTile() or something like that (http://www.palib-dev.com/manual). You should make sure you have the 3 different tiles all drawn in the background (on a imaginary 8x8 grid). Then they will be given a number which is calculatable by counting from left to right/up to down. Every new tile (not the same as earlier ones) is a new number.
here and yet not here
JanMulder
 
Posts: 726
Joined: December 30th, 2010, 3:08 pm

Re: REQ: More flexibility

Postby WillWill56 » August 7th, 2011, 3:38 pm

Exactly what I was going to suggest if I wasn't about to go to sleep while playing with the 3DS browser. With that many 8x8 sprites, a tiled backround with 8x8 tiles is much easier and more efficient.
WillWill56
 
Posts: 145
Joined: April 15th, 2011, 3:02 pm

Re: REQ: More flexibility

Postby JanMulder » August 7th, 2011, 3:48 pm

Nice Will :). You seem as experienced as I am (if not more). It's nice that there are more people with my level on the forum.
here and yet not here
JanMulder
 
Posts: 726
Joined: December 30th, 2010, 3:08 pm

Re: REQ: More flexibility

Postby Leon » August 7th, 2011, 5:29 pm

Yep, you're right. But how do graphics work with that? How do I specify which sprite becomes which tile? It sounds promising if I can find out how to use it. I don't understand how from
Code: Select all
PA_SetMapTile (screen, bg_select, x, y, tile_number)
tile_number refers to a sprite.

I found an article on the old DSGM 4.9 forum from James but the images don't show (or are removed).
I've looked at several examples and manuals but can't get it to work... :(
Probably I'm completely missing the point... :roll:
Leon
 
Posts: 13
Joined: July 11th, 2011, 7:11 pm

Re: REQ: More flexibility

Postby JanMulder » August 7th, 2011, 7:32 pm

Ok. You have a background 256x192, that's 32x24 in 8x8 tiles.
If you hit compile in DSGM the background is "scanned" and divided in some variables. The program that scans the background looks whether there are identical tiles on the background (or almost identical (flipped or rotated)). It checks every tile starting at the left-top and ending at the right-bottom. If it sees a new tile, a tile not identical to any tile he saw earlier, it adds it to a tile data variable and gives it the new number (if the first 0, if the second 1, etc). It also makes a tile map, which tile (in coords) gets which tile number.

Ok so if you put the first sprite in your png/bmp/whatever background it is clever to put it top-left (since you it gets tile number 0 then). You can place the second sprite right next to the first and you will know it gets tile number 1 etc.

Once you have done that you can add the background in DSGM. If you use the function PA_SetMapTile you can change all tiles on the background. Say you put the background on layer 2 on the bottom screen:
Code: Select all
PA_SetMapTile(0,2,3,4,1);

This sets the tile with coord (3,4), or (24,32) in pixels, to tile number 1.

Sorry for my limited English.
here and yet not here
JanMulder
 
Posts: 726
Joined: December 30th, 2010, 3:08 pm

Re: REQ: More flexibility

Postby Leon » August 7th, 2011, 10:18 pm

Je Engels is perfect hoor!

So far, so good, I got this working. I understand now how the tiling system works regarding the location of the tiles. Also how to 'swap' them. But... (why is there always a but.. :) ) a load of questions arise.

Is it possible to have a sprite-sheet (background 0) and select tiles from here to show on background 1?
Is it possible to have transparent tiles? I know there's a palette for tiles but that's for the whole background, not just the selected tiles.
Is there a way to see if a tile is touched instead of returning stylus' screen coordinates?
Is it possible to return a tile to it's original state without resetting the complete background?
Is it possible to pixel-shift a tile? Take the default tile numbering and place them on a pixel-coordinate instead of tile-coordinate?

Sorry for all the questions but I can't find any info/examples/explanations of the tiling, other than the definition statements shown in the manual(s).
Leon
 
Posts: 13
Joined: July 11th, 2011, 7:11 pm

Re: REQ: More flexibility

Postby JanMulder » August 7th, 2011, 10:50 pm

1. Yes, but you will need the same tilesets in both of the backgrounds.
2. Just add a magenta tile.
3. Stylus.X/8 gives the x coord of the tile touched.
Stylus.Y/8 gives the y coord
4. Not sure if that is possible with only one function
5. No.
here and yet not here
JanMulder
 
Posts: 726
Joined: December 30th, 2010, 3:08 pm


Return to Improving DSGM: Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron