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.

Newcomers DBPro Corner / Sprites confusing me

Author
Message
Bush Baby
19
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 28th Apr 2010 10:02 Edited at: 28th Apr 2010 10:06
I am using DBpro and I am attempting to create a 2D turn based strategy game. It is tile based and I'm having difficulty moving my soldiers.



The above is the sub routine I used to assign the unit's new position. This appears to work fine. But here is where I run into my problem:



When I position the unit... none of the data I want follows it. It just simply pastes the image... but I want it to hold all the data associated with that unit in the array. So I end up with the original unit with all the data... and the new pasted one with no data. So two units.. but only one I can do anything with.

I just want to actually reposition the sprite itself to the new x and y coordinates. But I don't see any useful commands for this. Offset sprite does not look like (if I read correctly) it would change the sprites coordinates... it would just change where the sprite image is pasted.

If I need to post more code, I will. But it's a messy bunch of subroutines

the update_units subroutine is used in the loop.
Bush Baby
19
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 28th Apr 2010 11:13 Edited at: 28th Apr 2010 11:25
I am using arrays with custom types. (If this helps any)



^ How the tiles are defined



^How the units are defined


^ How the tiles were created and array data filled (no problems here, I'm pretty sure)



^How I initialized the units array



^The sub routine used when creating new soldiers

I am not surprised if this will look confusing: it is.
I have a lot of sub routines... which should probably be functions. But I've taken a lay off from programming for a while (only ever did it leisurely). I plan on tidying it up a whole bunch... but I first want to get this sprite issue worked out.

How do I change the coordinates of the actual sprite?

I don't want to just paste its image somewhere else. All data in the array corresponds with the actual sprite.

I'd prefer not to change the basis of the array.. as it is the basis of my concepts and the way I was going about it all. I'd just like some tips! Thanks!
Bush Baby
19
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 28th Apr 2010 12:19
Nevermind, I figured it out.

Offset sprite does do what I want to do.. when used in combination with a for loop to match the x and y of the sprite with the tile exactly...

guess I misunderstood the description.

Thanks anyway.
Bush Baby
19
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 29th Apr 2010 00:27
Storing the sprite number and deleting it and then creating a new works much better. Just thought I'd put it out there that I discovered that on my own.

Login to post a reply

Server time is: 2024-11-23 17:01:45
Your offset time is: 2024-11-23 17:01:45