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.

DarkBASIC Professional Discussion / Need some fresh eyes on this piece of code...

Author
Message
Grumpy Jedi
16
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 17th Aug 2010 08:55
This section of code should be updating a sprite's position to one of 5 spots from left to right...

The code fails to update the sprite's position.




Now what did I miss...
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Aug 2010 09:08
Maybe if you simplified the code a little . . . just to make it a bit easier to read, because not many people like to sit down and try to work out how the code is supposed to work and thus you won't get many replies. I might if I get time liater on.

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Aug 2010 09:36
Your not changing the sprite position though, your using POMarkerPosition to set the sprite image, but positioning it mid screen everytime.

Health, Ammo, and bacon and eggs!
Grumpy Jedi
16
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 17th Aug 2010 09:59
Now I KNOW I'm tired.

What I said above doesn't even apply to this code because it's something I was doing earlier...

This piece of code doesn't move the marker you are completely correct Van.

It changes the image of the sprite, which has markers in different positions...

However...the sprite is not updating to its new image...

Just as a side note, if the code within the function is run as a subroutine from the main loop, instead of as a function, it works perfectly.

I've checked that all variable values are updating correctly inside the function, and they are.

Any Ideas?
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 17th Aug 2010 12:06
If i understand you, the purpose of this code is to change image of some sprite that is allways drawed at center of the screen.If that's the case, i made 5 dummy images just to work with because there is no media attached.I cut 2 lines of code because the first contains few variables that aren't provided so i didnt know what values to put in there.Second line is same as the one above the 2 so it does the same and without the values of the missing variables is pointless to be there.

What i've changed is POKeysUp flag to global boolean variable.It needs to be global or function won't work.

Also touched sprite width and sprite height values to match sprite number that's used, in this case sprite 3.

@Clonkex - It wasn't that complicated after all.



Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Grumpy Jedi
16
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 17th Aug 2010 12:34
Thanks luskos, Global POKeysUp was precisely what I missed.

Your Kung Fu is strong indeed.

I am going to go practice the "Sleeping Dragon" style now.

Thanks.
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 17th Aug 2010 13:45
I'm just glad to help.Good luck with the game

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 18th Aug 2010 00:25
Lol, glad you got it sorted out.

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.

Login to post a reply

Server time is: 2026-07-24 20:35:27
Your offset time is: 2026-07-24 20:35:27