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 - Problem with Ink command

Author
Message
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 15th Oct 2005 23:52 Edited at: 24th Oct 2005 02:34
What is wrong here?

When you run it, it only shows a blank screen.

Grossman
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Russia
Posted: 16th Oct 2005 03:53
Ink command is definitely innocent. The second box command removes effects of all previous commands, because
box x, y, x+a, y+a is equal to box x+a, y, x, y+a .
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 16th Oct 2005 04:22 Edited at: 24th Oct 2005 02:34
How embarrising. It was supposed to be Line. I can't believe I missed that.

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 16th Oct 2005 04:25 Edited at: 24th Oct 2005 02:34
Here is the updated code. It still doesn't work.

Sorry about the double post. I am still being noob slapped and it hasen't appeared yet, so I can't edit it.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2005 00:23
Check out the Code Hints on my web site for how to get faster colours in DB - there's a better way to do it than the way you have used.

As for your code, although you DIM'ed the array Map$ you didn't initialise it. Once you say that every element of the array equals "" then it works.



TDK_Man

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 17th Oct 2005 00:52 Edited at: 24th Oct 2005 02:34
Ok. I'll try that. Thanks.

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 17th Oct 2005 01:47 Edited at: 24th Oct 2005 02:34
It works!
The faster colors doesn't speed it up much though.
I made it faster by first drawing the first row, and then copying it and pasting the whole row down for the y size. Since it is copying the first row, the cells in the other rows will now be displayed, only the first row's, this will only be for the begining and new cells added will only paste the one new image. Thanks for your help.

*******EDIT*******

I fixed it and added a bunch of stuff. Now I am having trouble with either an array or writing to a file. Whenever I save the map it writed the x and y size, but not the tile numbers.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2005 07:33
Quote: "The faster colors doesn't speed it up much though."


No, just changing the Ink command won't speed your program up enough to notice it. It's a cumulative effect so you need to stop using the method you use now, so you don't get into the habit. You still have:

Ink rgb(0,0,0), rgb(0,0,0)

when you should be using

Ink 0,0

Also, you didn't say that the speed wasn't a problem, so I didn't optimize it. If you wanted to speed your code up, you would do it like this:



As you can see, it draws instantly without having to grab and paste images.

Quote: "Whenever I save the map it writed the x and y size, but not the tile numbers."


Apart from the fact that the Close File 1 is missing, there's nothing wrong with your savemap procedure. It's working fine, it's just that the array map$(x,y) doesn't contain anything so it's writing out blank lines.

The reason it doesn't contain anything is because the Input command only works with normal numerical or string variables - NOT arrays. If you use an array, it runs, accepts your input then instantly forgets it!

Instead, use this:



Oh and one last thing, indent all of your code - not just the loops. You'll find it a lot easier to spot errors. I nearly missed the Close File line wasn't there as it wasn't indented. Look how much easier it is to spot with indentation:



TDK_Man

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 18th Oct 2005 02:03 Edited at: 24th Oct 2005 02:34
Thanks. I will try that when I have time.

Edit
I finally had time to try it...

It works!!! Thanks TDK!

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 22nd Oct 2005 01:15 Edited at: 24th Oct 2005 02:34
Ok. I added alot of new stuff, but I have another bug that I can't figure out.

New Code:


Whenever you run it, choose to load a file, and type the filename in, the program works fine untill it runs into the place where it draws it and it says - "Runetime error at line 120. Image does not exist"

Can you please help?
I attached a sample map file. You can load that file. If you want to make a different one for whatever reason, choose to make a new map file at the begining. Then after the blank map is drawn, press h and it will tell you what to do. The characters for tiles are the characters that it writes to when you save it for tile 1, tile 2, etc.

Attachments

Login to view attachments
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 23rd Oct 2005 23:46 Edited at: 24th Oct 2005 02:35
Please help. Sorry about the triple post.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Oct 2005 06:23
Error messages never lie - it's the line numbers that tell porkies!

You know what the error is, so go and double-check all the lines which load images and make sure that the filenames you use exist as files on the disk.

TDK_Man

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 27th Oct 2005 02:57 Edited at: 27th Oct 2005 02:57
I don't use picture files in this program. I made sure all the numbers in the map file it saves are in-between 1 and 5 - the image numbers. For some reason it trys to paste an image with a number I didn't use. After I ran it and it stopped because of the error, I typed Print x and Pront y - the variables used in the Nor - Next loop right above the line # it said was wrong. It was 51 for both. The array is only Map(50,50) and Map(x,y) was used. That could have contributed to the error. Here is where the error ocurrs. I should have shown it when I posted the code before. Sorry.



Quote: " Error messages never lie - it's the line numbers that tell porkies!"


But sometimes it points to the wrong line. Like in my Map editor program.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 27th Oct 2005 06:38
Quote: "For some reason it trys to paste an image with a number I didn't use."


When you gosub to Loadmap you don't have it create the tiles before gosubing to Drawmap. You need to add "gosub Maketiles" before "gosub Drawmap" in the Loadmap routine. Doing that will create another bug but will be solved if you move "Tilesize = 10" and "Selectedtile = 2" to right under "sync rate 0". It's best to always define things at the begining of the program for two reasons (at least).

1. You know exactly where to look if you want to change them.

2. Putting it on top makes sure everything is defined before any other code is ran.

Quote: "But sometimes it points to the wrong line. Like in my Map editor program."


"sync on" causes errors to be reported on the wrong line.

Also I noticed that you use "mousex" and "mousey" as the variables... if you ever plan on going to Darkbasic Pro... you need to make sure that any variable you use is not the same text as a command. Darkbasic Pro hates that.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 27th Oct 2005 13:49
Oh... When you choose to load a map it skips the make tiles part. Thanks! I will try that when I have time (probably this afternoon).

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 27th Oct 2005 20:50
Quote: "Oh... When you choose to load a map it skips the make tiles part. Thanks! I will try that when I have time (probably this afternoon)."


Np. Really it should be done even before asking the question if you want to load a map or make a new one. Making tiles is like the graphic setup of this program... so if it's done first after any variable defining you don't have to have two "gosub Maketile"'s... just one close to the top of your code.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 29th Oct 2005 04:04 Edited at: 29th Oct 2005 04:04
OK. I got it to work. Now, it won't let me draw a box. I tell it to and it won't. Why?


Here is the part that doesn't work:


It's not saying there is a bug or anything, it just won't appear...

Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 29th Oct 2005 04:21
Your setting the ink to black. What's the color behind the box your making?

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 29th Oct 2005 15:51
This is what is wrong:

A box has some rules before displayed:
1- The first coordinate has to be the most top-left coordinate. Else, the box will not be displayed.

2- Both coordinates have to be IN the screen. Else, the box will not be displayed.

In this case, nr2 is the problem:
You're display mode is probably 1280x1024xdepth.
So this means that the screen width = 1280 and the screen height = 1024. But, But where most ppl go wrong is, that these values are not the maximum coords. A pc starts counting from 0, wich means that 1 -> 1280 has to be 0 -> 1279 and 1 -> 1024 has to be 0 -> 1023

The biggest box that can be displayed in this display mode is
box 0,0,1279,1023

Immunity and Annihalation makes Immunihalation...
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 29th Oct 2005 16:39
Cool! It works!.
@ Antidote - I am making the black box there to cover the text at the bottom of the screen, instead of clearing the whole screen and drawing it all over again.

Sorry about all the questions... I just haven't gotten this far into a program before, so I am not used to some of theese bugs. I can fix 80% of the bugs I run into though...

Thanks Sven B

Login to post a reply

Server time is: 2024-09-24 07:24:18
Your offset time is: 2024-09-24 07:24:18