Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbSprite only pasting sprite in one position

Author
Message
Metroid Larvae
15
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 24th Oct 2008 23:48
Here is my code:

int template1[12][12] ={
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,4,4,0,0,0,0,0,
0,0,0,0,0,4,4,0,0,0,0,0,
0,0,0,4,4,4,4,4,4,0,0,0,
0,0,0,4,4,4,4,4,4,0,0,0,
0,0,0,0,0,4,4,0,0,0,0,0,
0,0,0,0,0,4,4,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0
};

dbLoadImage ( "left_tile.png", 7);

//First column
int j = 0;
for(int i = 0; i <= 12; i++,j++)
{
if (template1[i][j] == 0)
dbSprite (7, i, j * 31, 7);
}
----------------------------------------------------------------
The left_tile image is only pasted on the screen in the last postion and nowhere else. I need the same sprite to be pasted in several locations from the same source image in order to make a Pacman maze. Why isn't this code working?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Oct 2008 00:02
There's only one sprite, and you're just moving it around. The point of sprites is that they are movable, not permanent.

Try using dbPasteImage instead of a sprite.

Metroid Larvae
15
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 25th Oct 2008 02:45
For some reason, when I use dbPasteImage (7, i, j * 31); nothing at all shows up on the screen. And yes it is in the right folder, so I know it exists.
go2none
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location: London
Posted: 25th Oct 2008 12:46 Edited at: 25th Oct 2008 14:07
Is this what you are looking for?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Oct 2008 15:45
@Metroid Larvae,
Either the image isn't being loaded correctly (unlikely as you can make a sprite from it), or you aren't syncing and updating the display, or bitmap 0 isn't the current bitmap.

Post a complete example project with test media - make it easy for us to help you.

Metroid Larvae
15
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 26th Oct 2008 03:50
Ok. Here you go.

Attachments

Login to view attachments
ErDa
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 26th Oct 2008 04:25
You've almost got it.



If you want to add additional tiles, which you probably do, Use:



However then the Image ID's of the tiles have to be the same as in the array. As in :

Metroid Larvae
15
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 29th Oct 2008 19:18
@ErDa

So I used your algorithm and the images paste to the screen but in the wrong position. I recoded your oriinal algorithm because it was giving me an error. I am also using the real map this time instead of the template map that I was just trying to test.

void DrawMaze()
{
if (Level == 1)
{
int maze[19][22] = {
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,8,8,8,8,8,8,8,8,7,8,8,8,8,8,8,8,8,7,
7,9,7,7,8,7,7,7,8,7,7,7,7,7,8,7,7,9,7,
7,8,7,7,8,7,7,7,8,7,8,7,7,7,8,7,7,8,7,
7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,
7,8,7,7,8,7,8,7,7,7,7,7,7,7,8,7,7,8,7,
7,8,8,8,8,7,8,8,8,7,8,8,8,7,8,8,8,8,7,
7,7,7,7,8,7,7,7,0,7,0,7,7,7,8,7,7,7,7,
0,0,0,7,8,7,0,0,0,0,0,0,0,7,8,7,0,0,0,
7,7,7,7,8,7,0,7,7,7,7,7,0,7,8,7,7,7,7,
0,0,0,0,8,0,0,7,0,0,0,7,0,0,8,0,0,0,0,
7,7,7,7,8,7,0,7,7,7,7,7,0,7,8,7,7,7,7,
0,0,0,7,8,7,0,0,0,0,0,0,0,7,8,7,7,7,7,
7,7,7,7,8,7,0,7,7,7,7,7,0,7,8,7,7,7,7,
7,8,8,8,8,8,8,8,8,7,8,8,8,8,8,8,8,8,7,
7,8,7,7,8,7,7,7,8,7,8,7,7,7,8,7,7,8,7,
7,9,8,7,8,8,8,8,8,0,8,8,8,8,8,7,8,9,7,
7,7,8,7,8,7,8,7,7,7,7,7,8,7,8,7,8,7,7,
7,8,8,8,8,7,8,8,8,7,8,8,8,7,8,8,8,8,7,
7,8,7,7,7,7,7,7,8,7,8,7,7,7,7,7,7,8,7,
7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};

//int template1[12][12] ={
//7,7,7,7,7,7,7,7,7,7,7,7,
//7,8,0,0,0,0,0,0,0,0,0,7,
//7,8,0,0,0,0,0,0,0,0,0,7,
//7,0,0,0,0,9,9,0,0,0,0,7,
//7,0,0,0,0,9,9,0,0,0,0,7,
//7,0,0,9,9,9,9,9,9,0,0,7,
//7,0,0,9,9,9,9,9,9,0,0,7,
//7,0,0,0,0,9,9,0,0,0,0,7,
//7,0,0,0,0,9,9,0,0,0,0,7,
//7,0,0,0,0,0,0,0,0,0,0,7,
//7,0,0,0,0,0,0,0,0,0,0,7,
//7,7,7,7,7,7,7,7,7,7,7,7
//};

dbLoadImage ( "tile.png", 7);
dbLoadImage ( "dot.png", 8);
int mazeX = 0;
int mazeY = 0;
int SpriteID = 7;
const int SizeOfSprite = 30;

//Traverse the rows
while( mazeX < 19)
{
while (mazeY < 22)
{
dbSprite(SpriteID,mazeY * SizeOfSprite ,mazeX * SizeOfSprite,maze[mazeX][mazeY]);
mazeY++;
SpriteID++;
}

if (mazeY == 22)
mazeY = 0;
mazeX++;
}

}
}
Metroid Larvae
15
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 31st Oct 2008 04:43
Never mind I got it to work. Thanks for all of your help.
SunDawg
19
Years of Service
User Offline
Joined: 21st Dec 2004
Location: Massachusetts
Posted: 31st Oct 2008 20:42
It might help you, in the future, to use to /* and */ to comment large blocks out. Instead of putting // in front of every line of code, just put /* in front of the first one and */ at the end of the last one.




My site, for various stuff that I make.

Login to post a reply

Server time is: 2024-09-30 09:27:26
Your offset time is: 2024-09-30 09:27:26