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 / DBC - For - Next Loop Problem

Author
Message
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 16th Oct 2005 16:19 Edited at: 25th Oct 2005 02:41

A screenshot is attached. Please help. I know the problem is in the For - Next loop where it draws the tiles on the screen.

Attachments

Login to view attachments
Freddy 007
19
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 17th Oct 2005 00:05
Please explain your plroblem in details.
What happens? What was SUPPOSED to happen?

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Oct 2005 00:25
You are positioning your tiles relative to a variable called tilesixe which has no value and so zero will be used.

Perhaps you mean tilesize which does have a value


Great Britain would be Amazing Britain if it wasn't for idiots like you bringing down the average!
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 17th Oct 2005 00:50 Edited at: 25th Oct 2005 02:41
whoops. That is the problem. Thanks.

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 17th Oct 2005 01:21 Edited at: 25th Oct 2005 02:41
Here is the new code:

It still doesn't work. It looks like this now:


Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Oct 2005 04:07
Did you know if you used numbers instead of strings you can save yourself some trouble?

If the map data are all numbers you can use them as the image numbers... saving yourself some extra coding checking the string to determine what image number to use.

I hope you don't take offense to this.

Code example of using numbers instead:
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 18th Oct 2005 02:06 Edited at: 25th Oct 2005 02:42
I will do that once it gets fixed. I don't want another thing that could cause a bug untill after I get rid of all the bugs already there.

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 21st Oct 2005 00:48 Edited at: 25th Oct 2005 02:42
*bump*
Please help!!!

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Oct 2005 02:15
Without all the media it's hard to test... but it seems to me your overcomplicating the tile placement.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 22nd Oct 2005 01:09 Edited at: 25th Oct 2005 02:42
Here is the media...

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 22nd Oct 2005 05:39 Edited at: 22nd Oct 2005 05:47
It's just as I thought... overcomplicating. It's the for/next loops. The following code does not fix it... it just shows you why it's not working. I added a screenshot for quick reference.



Because the x and y start way beyond the map data you get a whole bunch of "Nothing"'s.

Attachments

Login to view attachments
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 22nd Oct 2005 16:15 Edited at: 25th Oct 2005 02:42
What should I do then?

I'm not sure what you mean by

Quote: "Because the x and y start way beyond the map data you get a whole bunch of "Nothing"'s"


Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 22nd Oct 2005 21:01
Quote: "What should I do then?

I'm not sure what you mean by

Quote: "Because the x and y start way beyond the map data you get a whole bunch of "Nothing"'s""


Look at the picture. In the first tile location (upper left corner) it says "Nothing" and right under that it says that "x=-4" and "y=-3". In the code the map data loaded goes from 1 to 68 for x and 1 to 65 for y. So if x is -4 and y is -3 then you don't have any data for that tile location because it is beyond 1 to 68 and 1 to 65. "Nothing" is written because of this line:



Meaning if map$(x,y,level,1) = no text at all... change it to "Nothing". I did that to show you that when you see "Nothing" that means the data for that location is non-existant.

You need to change x to start at 1 and y to start at 1... or move the "down" farther into the map so that you don't see "Nothing" data.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Oct 2005 00:35 Edited at: 25th Oct 2005 02:42
Ok. Your post helped me figure out the problem. The Playerx and Playery variables are 0 when they aren't supposed to be. I had this code in the program that got the playerx and Playery coordinates from the Level.map file. For some reason it doesn't work. The part in the file that says "down" is where the player is supposed to start. Here is the code that was supposed to do that:

The second part is the part that looks through the map array for the down thingy.

Edit: After it looks for "down" I added:

which is what they are supposed to be and it worked. I attached the screenshot. So the problem is in the Load Map part.

Edit (again): Ok. I fixed it. I had Mapsize(level) instead of Mapsize(level,1).

Thanks for your help!

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Oct 2005 01:26
Quote: "which is what they are supposed to be and it worked. I attached the screenshot. So the problem is in the Load Map part.

Edit (again): Ok. I fixed it. I had Mapsize(level) instead of Mapsize(level,1)."


(looking at the picture) Ah... much better.

Quote: "Thanks for your help! "


np
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 24th Oct 2005 00:21 Edited at: 25th Oct 2005 02:42
ok. I added some more, but encountered another bug I con't figure out.



The player won't move.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Oct 2005 05:30
Quote: "The player won't move."


It seems to be working to me. It's just a little messed up because you don't have any checks for the player limits... so it goes off the map data pretty quick.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 24th Oct 2005 14:51 Edited at: 25th Oct 2005 02:42
Whenever I push the arrow keys the player just stays there and doesn't turn or anything. It isn't picking up the keyboard. I added
If shiftkey() = 1 then end
in the loop, but it didn't do anythingy if I pressed that either.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Oct 2005 20:26
Quote: "Whenever I push the arrow keys the player just stays there and doesn't turn or anything. It isn't picking up the keyboard. I added
If shiftkey() = 1 then end
in the loop, but it didn't do anythingy if I pressed that either.
"


Sorry I looked at it with Pro. I messed with it a little bit... it's strange because in Classic your code tends to freeze up. When I remed off the placement of the players sprite it worked... but the map routine is still flawed so it's not working properly. I really think you need to convert your string map to numbers before you go on.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 24th Oct 2005 23:50 Edited at: 25th Oct 2005 02:42
I'll try that when I have time.

Thanks

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 29th Oct 2005 16:49
I tried getting rid of the pasting the player sprite, but it still doesn't work. I haven't been able to try this because I have been busy with my Map Editor Program.

Quote: "I really think you need to convert your string map to numbers before you go on."


Um...sorry. I don't want to do that because it always ends up making more bugs. I don't want to use numbers because it would be hard for me to know which number is what tile. I know there are probably a hundred reasons why it would be easier, but that is how I program.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 30th Oct 2005 03:22
Quote: "I tried getting rid of the pasting the player sprite, but it still doesn't work. I haven't been able to try this because I have been busy with my Map Editor Program.

Um...sorry. I don't want to do that because it always ends up making more bugs. I don't want to use numbers because it would be hard for me to know which number is what tile. I know there are probably a hundred reasons why it would be easier, but that is how I program."


Right. One of the first things that people do is make an editor like you're doing. You don't need to know what number equals what tile because you can make it so you don't even see the numbers because you load/save maps in the editor.

It's ok... we all have our own styles of programming.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 30th Oct 2005 14:59 Edited at: 30th Oct 2005 14:59
Never Mind...
I trashed this project. I will try again once I finish my editor.

Login to post a reply

Server time is: 2024-11-27 14:37:56
Your offset time is: 2024-11-27 14:37:56