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 / why won't my code work (paint program)

Author
Message
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 12th Jun 2009 19:06
The line isn't showing up





Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 20:16
because wen u say what oldx and oldy are you havent specifyed mousex and mousey, so those variables are equal to 0

so 0-.0001 = -.0001

and if the line or box command specifys a coordinate off screen then it wont draw

reverse this:



to this:



and it should work

There are only 10 kinds of people in the world, those who understand binary and those who dont
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Jun 2009 20:17
Can't test the code here, but it looks like you never used the ink command. You made the background white and the default ink color is white (or REALLY close to it). So your line is probably showing up, it is just White on White.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 20:19
that as well but i would assume he noticed that, if he tested his code

There are only 10 kinds of people in the world, those who understand binary and those who dont
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 20:23
sorry for dp

but look into the select, endselect, case, endcase, and case default command family, they could really help clen up this code

There are only 10 kinds of people in the world, those who understand binary and those who dont
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Jun 2009 20:30
They would but I believe I have cracked the case:

At the top your code you use INPUT. Input will wait for the user to press enter before continuing. It will then run through all of the code under it and then hit input again and wait. The problem is that the user would have to click at the EXACT moment that the program hits the IF MouseClick() or it would be back to input. Try looking into either making your own real time text input system using ENTRY$() (there is a pretty cool example that comes with DarkBASIC) or find another wait to accept the users choices (everyone loves buttons )

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 12th Jun 2009 22:17 Edited at: 12th Jun 2009 22:37
Smart guy umm... it didn't work but good try and bn2 I know its not white on white because when I type in a different color it is still the same.

Edit:Why is the ink not the right color beacuse I said ink 0




Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 00:18
Your clearing the screen every cycle therefore your drawings arent showing up =)
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Jun 2009 00:23 Edited at: 13th Jun 2009 00:25
Ok well this won't do
Try to run it and see what happens

Edit:Not trying to be harsh i'm a half sarcastic half slightly angry additude its in my nature so don't take my poast the wrong way if i'm rude I don't mean to be.(hehe mean...)




Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Jun 2009 00:29
look through my post on the other thread arby

There are only 10 kinds of people in the world, those who understand binary and those who dont
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Jun 2009 00:31
on what thread?


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Jun 2009 00:39
the how to change foreground without affecting background, you already saw it tho

also that title is backwards, it should be how to change background without affecting foreground

There are only 10 kinds of people in the world, those who understand binary and those who dont
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Jun 2009 01:03
yoyyoyoyoyooyoyoyoyoyooyoyoyoyoyooyoy


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 04:53
I finally figured out why your code isn't working. lol
You have the input command on each line which stops the program until you enter something and if you enter something it constantly clears the screen.

I'll give you a working code in a min.
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Jun 2009 05:30 Edited at: 13th Jun 2009 05:34
cool

Edit:

Wait... you actually found a way to make it work I thougth that it was impossible hallelueja


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 06:40
hardly lol if you can call this working. I realized that the hardest thing to do was change the background color by clearing the screen, while still keeping the image you have drawn on there.
It lags when you change the color and when you change from blue to white, it clears everything. If i figure out why its doing that, i'll give you an updated code.

what i did is took the current screen color, got an image, put it in a memblock, cleared the screen, compared the image colors in the memblock to the point i took on the screen, and then changed the color if the current point matched the one i took from the screen.

Here's the code:



its got ok fps besides when changing the screen color.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Jun 2009 06:41
no offense to arby but dont you think he's a little....... inexperienced to understand memblocks?

There are only 10 kinds of people in the world, those who understand binary and those who dont
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 06:54 Edited at: 13th Jun 2009 06:55
maybe, but after i realized how difficult it was, I kinda made it a project of my own to finish lol. Also, this may help him understand them a little better, you never know.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Jun 2009 07:03
Why do you need memblocks? just save the color selected and then use:

cls BackColor

or

Ink White,BackColor

You don't need to do that with memblocks

New Site! Check it out \/
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 07:10
because when you clear the screen, it gets rid of the drawings you made with the mouse, so you have to save the drawings part as an image, but when you save it as an image and paste it again, its going to have a white background. So i took it, put it in a memblock found the areas with the white background and changed em to whatever color they were setting the background as.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Jun 2009 07:16
If he is making a paint program he is going to need a image of the drawing anyway. although he could use memblocks to draw and zoom and stuff, but for a beginner paint program it's best to use simple things like line,get image,paste image,cls that kind of thing.

No offense saying "Beginner" Stuff as i see you Joined just after i did last year Arbiter but you have said yourself you just learning text and 2d stuff.

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Jun 2009 08:11
pic wat do you mean white background?

There are only 10 kinds of people in the world, those who understand binary and those who dont
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 09:23
when i say white background i'm basically trying to refer to any color the background can be, just used white because its the one you start out with.
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Jun 2009 15:09 Edited at: 13th Jun 2009 15:14
Ok but what exactly is a memblock because I want to understand everything before I just put it in my code or else what do I learn from it?

Edit:
Oh and the background color is only in the top quarter of the screen the rest of the screen is white.


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 13th Jun 2009 17:45
Here's a post I made a little bit ago when I didn't understand memblocks.

http://forum.thegamecreators.com/?m=forum_view&t=150753&b=10
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Jun 2009 18:59 Edited at: 13th Jun 2009 19:02
Oh I get it now the image is stored in a memblock and when cls is cycled in the loop the image is taken from the memblock and repasted on to the screen.

Wow i'm learning alot from the program I've learned two new things wih the help of smartguy and pictionary
I can add more to my programs and I think I figured out how to save games in a more professional game

Who you callin' inexpierienced



edit:
An alternative to the input command




Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
Grog Grueslayer
Valued Member
20
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Jun 2009 19:12
I know you're just starting out but you can make it easier for yourself and the user by mimicking what normal paint programs do to select colors.

There's no need to have the user type in names (especially when there's 16 million colors to choose from). Just grab any color box from any good paint program, put that color box on the screen and use the POINT() command. It grabs the color from the screen at a specific x and y coordinate. Use POINT(MOUSEX(),MOUSEY()) and add saving that color from POINT() with the mouse button and you've got all the colors you need without asking the user to type them in at all.

You can even separate that color with the RGBR(), RGBG(), AND RGBB() commands to get the specific red, green, and blue content that makes that color.

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Jun 2009 22:44
Point is VERY slow.

If you REALLY DO understand memblocks, make a memblock of your color picker image and use that to get the color of a specific point on the image.

memblocks are WAAAAYYYY faster on most things. i stress most though. sometimes it's just useless to use them though lol.

New Site! Check it out \/
Grog Grueslayer
Valued Member
20
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Jun 2009 23:20 Edited at: 13th Jun 2009 23:23
Quote: "Point is VERY slow."


It used to be slow in Darkbasic Classic but not anymore.

In this code that works in both Classic or Pro the only delay is waiting for it to draw the lines (in Classic). Using point itself is very fast.



BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 14th Jun 2009 01:28
The problem I have always had with POINT performance issues is that it seems to force a refresh of the screen. This usually will cause flickering and lower fps.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 14th Jun 2009 01:48
Thats what i was talking about bn2. if you use point in a loop then that is causing 2 syncs per loop.

New Site! Check it out \/
Grog Grueslayer
Valued Member
20
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Jun 2009 07:25
Yes but you can program it to only check using point when the mouse is over the color box and only when the left or right mouse buttons are clicked. A small color box like in Paint Shop Pro is only 61x115. Surely the benefit of quickly picking colors in a small area like that for a few seconds outweigh any FPS issues we may experience.

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 14th Jun 2009 11:22
Or you could write your own using memblocks, thats what I did. It doesn't force a refresh and I haven't had any trouble with it.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Jun 2009 11:58
Point is actually quite fast if you don't use it with a sync. Point calls a sync and that's why it seems so slow when you have a sync following it because calling syncs in succession increases the time it takes to get through a loop iteration + any time for math or redraw recalculations. Even if you see the frame rate increase with multiple syncs, the only thing that has increased is the frequency of syncronization, how many times in a loop everything is lined up so to speak, but each time everything is syncronized, the iteration time of the loop increases. Never mind the details of what's happening, just understand that multiple SYNCs in a row slows down the overall loop time - and calling point() then calling SYNC is the equivlanet of two SYNCS in a row.

If you wanted to constantly check the colors under the pointer, don't use a sync in your loop and use point as the sync. This example will loop 500 times and output the time it took to use point() as the sync without ever calling sync.


Now if you add a sync after the point command the time it takes to get through 500 loops increases:



What does this mean? It means the more syncs in a row, the more time it'll take to get through a loop. That makes POINT() impractical for scanning through an entire image or a bitmap in a loop one pixel at a time, because after each pixel, the screen will be synced. But it becomes very practical for finding the color in a color box in the manner Grog Grueslayer suggests if you use POINT() as not only the color finder but as the sync for the entire main loop.

Enjoy your day.
Grog Grueslayer
Valued Member
20
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Jun 2009 10:25
Quoting BN2 Productions:
Quote: "Or you could write your own using memblocks, thats what I did. It doesn't force a refresh and I haven't had any trouble with it."


I'll have to try that when I need a break from my current project. I love experiments.


Quoting Latch:
Quote: "What does this mean? It means the more syncs in a row, the more time it'll take to get through a loop. That makes POINT() impractical for scanning through an entire image or a bitmap in a loop one pixel at a time, because after each pixel, the screen will be synced."


I never actually noticed that in Classic POINT() forced a sync. I'll try to keep that in mind the next time I mention using POINT() in Classic.

I use it in Pro all the time to grab bitmap fonts and it never forces a sync... it slows down like it does sync but it doesn't. It takes about 400 milliseconds to use POINT() in Pro 1000 times.

Login to post a reply

Server time is: 2025-08-08 11:54:41
Your offset time is: 2025-08-08 11:54:41