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 / A little bit of help needed here

Author
Message
Andrzejef
14
Years of Service
User Offline
Joined: 26th Dec 2011
Location:
Posted: 14th May 2012 20:08
It seems it's me again.
I've got a problem with moving a sprite. After clicking somewhere on the map the tank should face that point and move forward until it hit that spot. But, in fact, it is rotating it do nothing else. And really frustrating is the fact I can't figure out what's wrong. Maybe you can help me?
The problematic code is attached, without images or sprites.
Thanks in advance and good luck.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2012 02:55 Edited at: 15th May 2012 02:57
Errrr, the dba file is of no use without media. There's 95% of the community at least here or more that won't be bothered stealing your code.

You could have just simple done this: (with a little added indentation)
Sowwy, but it didn't run as I don't have the media to test it and I was busy re-ka-jigging the formatting to read it.



And attached the media for those that needed it.

I tried reading through but it's late now... I'll re-check these posts tomorrow...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Andrzejef
14
Years of Service
User Offline
Joined: 26th Dec 2011
Location:
Posted: 15th May 2012 17:26
Ok, I packed it into zip file including sprites and tiles. Yes, I'm afraid it means formatting that again. And sorry for delay, I was busy for the major part of the day, so I couldn't respond.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th May 2012 15:58 Edited at: 16th May 2012 16:02
That program doesn't compile. It seems to be expecting some data statements but I couldn't find any.

Edit Suddenly it does compile - but there still aren't any data statements.
Andrzejef
14
Years of Service
User Offline
Joined: 26th Dec 2011
Location:
Posted: 16th May 2012 20:25 Edited at: 18th May 2012 08:41
ah, yes. I forgot about including map after excluding testpage from project. Here it is again. Complete I hope.

EDIT
And, any ideas what is malfunctioning?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th May 2012 13:02
Found your problem. You were positioning sprite 1 (the tank) at the old position each loop so it never moved. I think you should position the tank just once BEFORE the main loop then adjust its position using move sprite etc inside the loop.

I changed this:



to this:



It seems to work as intended now. There may be other problems of course.
Andrzejef
14
Years of Service
User Offline
Joined: 26th Dec 2011
Location:
Posted: 18th May 2012 13:23 Edited at: 18th May 2012 15:22
Ok, I'll check that and post results. Hope it'll be positive. Many thanks.

EDIT: Nope, that's not that. The 'sprite' command in main loop was due to updating position of sprite to screen borders (map scrolling). It (program) HAS to repeat that command. The next problem I found (instead of solution, unfortunately) is moving it. Sthe sprite rotates very well, but it moves in lines which - I think - makes 30, 60, 90 and so degree angle. What's intresting that problem occurs only when sprite command is after setting values for variables pox# and poy#
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th May 2012 17:11
Quote: "Nope, that's not that."


What happens when you try that fix? It works most of the time for me. I agree it's still not completely right. What you need to do is check carefully to see when things go wrong. For example, try printing out some variables at critical points. That usually tells me where things have gone wrong.

Quote: "The 'sprite' command in main loop was due to updating position of sprite to screen borders (map scrolling)."


Yes, but if you do it every loop as in the code you sent me then you simply undo the changes from the previous loop. You've got to fix that one way or another.
Andrzejef
14
Years of Service
User Offline
Joined: 26th Dec 2011
Location:
Posted: 19th May 2012 12:19 Edited at: 19th May 2012 12:23
What happens? It (tank) is moving correctly to the pointer, but it isn't changing its position when scrolling, because it's updating the variables all the time but not uses that to recreate the sprite at new position.
Quote: "What you need to do is check carefully to see when things go wrong."
I know when it goes wrong:
Quote: "the sprite rotates very well, but it moves in lines which - I think - makes 30, 60, 90 and so degree angle. What's intresting that problem occurs only when sprite command is after setting values for variables pox# and poy# "
I checked that and i'm a little bit confused 'cause I don't see a point.
Below I attached the code fragment which make me problems.


Quote: "You've got to fix that one way or another. "

I tried to delete sprite at the end of the loop and recreate it on new coords at the begining, but then I had the problem I mentioned above, or after changing some syntax additionaly position of the tank is not changing when scrolling.

If needed I will add whole problematic code.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th May 2012 13:22 Edited at: 19th May 2012 13:29
Well you are picking a position for sprite x(1).... and sprite y(1)...

pox#=sprite x(1)
poy#=sprite y(1)

...then passing it back to the same sprite....

sprite 1,pox#,poy#,11
...
sync
loop


So it will not move.


You need to pick a position with a different sprite...

pox#=sprite x(2)
poy#=sprite y(2)

to pass it to another sprite....

sprite 1,pox#,poy#,11

And if you want it to go slowly, you split the new position up into parts.

posx# / Distance#

With a distance routine, or track speed routine.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th May 2012 15:04
Quote: "Well you are picking a position for sprite x(1).... and sprite y(1)...

pox#=sprite x(1)
poy#=sprite y(1)

...then passing it back to the same sprite....

sprite 1,pox#,poy#,11
...
sync
loop


So it will not move."


Exactly. I think what needs to be done is to first wtite down in words what should happen and then make sure the code matches the words.

Quote: "but it isn't changing its position when scrolling, because it's updating the variables all the time but not uses that to recreate the sprite at new position."


I don't know what the problem is there. If your map is scrolling (which it doesn't seem to in the demo you posted) then you need to adjust the tank's position by the same amount. What's the problem with doing that?
Andrzejef
14
Years of Service
User Offline
Joined: 26th Dec 2011
Location:
Posted: 19th May 2012 16:43 Edited at: 19th May 2012 17:05
Quote: "If your map is scrolling (which it doesn't seem to in the demo you posted) "
Ah, It is there, you just need to move cursor close to the border of screen, but it's not important now.

You suggest to change the sprite what will govern the coords of the tank. Well, that doesn't work either. The tank stands still. Or, if declaring values for pox# and poy# is before creating sprite in main loop it isn't going to the point I've set.

EDIT:
Ok , I'VE SOLVED IT. I modified a bit the camera controling, from that:

to that:


So many, many and many more t(h)anks for your support, I'm really grateful for that. Have a nice day.

PostScriptum:
It's only temporary solution, until I will find out how to improve it (although in my country it's said that the 'better' is the enemy of 'good').
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th May 2012 20:03
Sounds like good news.

Login to post a reply

Server time is: 2026-07-22 02:24:42
Your offset time is: 2026-07-22 02:24:42