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 Discussion / newxvalue & newzvalue problem

Author
Message
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 11th Oct 2009 21:00 Edited at: 11th Oct 2009 21:48
OK I'm trying to ease myself back into this after my years of absence, and I was trying to figure out how to basically move some dots around a screen. Was doing alright, til I remembered I was rubbish, and promptly ran into a bit of a fix.

I have an array storing x and y positions of these dots, as well as their direction and colour. However they all head either left, up or somewhere in between the two - the angles seem limited to the 180-270 range. Also a few dots stay immobile and completely refuse to co-operate.

in BallArray:
(n,1) is x position
(n,2) is y position
(n,3) is object angle
(n,6) is irrelevant to the question but I thought I should include it because it was effort to remove that part, compared to the other bits.



Edit: By changing BallArray to a float array instead, the problem of staying immobile or only moving up, down or diagonally up and left has been solved. However there is now a stream going roughly from the bottom left corner to the top right corner.



I can't figure out why there are only a couple of directions it appears to move in.

"A West Texas girl, just like me"
-Bush
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 11th Oct 2009 21:46
Try using floats. You set your array to be a dword. dwords round the numbers to whole numbers (1,2,3,4...), but newxvalue and newzvalue return floats (0.67483,3.47363...). By adding a "#" behind the array or variable, you change it to a float. By adding a "$" you change it to a string. I was bored, so I did it for you:



So, have fun! There's no guaranty this will work because I didn't compile it. If there is a problem, check if I added the "#" after every array. If you have any further problems, please post!

TheComet


Make the paths of your enemies easier with WaypointPro!
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 11th Oct 2009 21:50 Edited at: 12th Oct 2009 03:55
@TheComet: Thanks, I'd just had a bash at that myself actually, but it's still problematic in that the whole random direction thing appears to be less random and more - sort of all in one of the same 2 directions...

Edit: Hmmm never mind, your new version works perfectly, whereas my amendment just created a different problem. I hope I haven't done anything too stupid. I'll have a little compare of the two...

One more edit: Never mind. I'd done something stupid in the middle when I was fiddling about. Let's not mention it. Thanks for the help mate.

Here's the code so far:


I'm hopefully heading towards a Chain Rxn style thing.
On the other hand I'm temporarily using a trial version of DarkBASIC until I can go home and pick up my disc.

In the meantime, I'm a bit drunk, and I've just found out I have 2 courseworks due in tomorrow (I though it was just the one, which I was going to do between when lectures finish at 10 and when it's due in at 3, but no, looks like all-nighter time.)

"A West Texas girl, just like me"
-Bush

Login to post a reply

Server time is: 2024-05-09 10:14:00
Your offset time is: 2024-05-09 10:14:00