Qbasicnews.com

Full Version: paint program, need help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
A game I’m working on right now uses 16x16 sprites, so instead of designing all of the sprites myself, I’ve decided to add a sprite editing part so you can make your own, and now I come asking for help, here is the code I’m using, I’ll put it into the main program later or I’ll make a stand alone sprite editor and use the same loading system that this will use in the main program to load the sprite, I just need this painting part to work, I put quite a few comments to help

Here is a link to my code, since it won't let me paste my code:
http://fbtext.piczo.com/?cr=3&rfm=y

Now my problems are the following:
-> How to use the BSAVE and BLOAD
-> If there would be a way to save the picture you make as a file so this program could be a stand alone and then how to load it in my game which is also screen 13,,,1
-> A way to draw a line through user input
-> A way to draw a circle through user input without going out of the drawing area box

Any help possible is much appreciated

Also, I need your opinion on my splash screen, it's not much, but so far there’s 3 possibilities:

[Image: pxintro13cm.png]
[Image: pxintro27kx.png]
[Image: pxintro34cp.png]

Just give your honest opinion on each one and suggest improvements on your favorite.
Big fucking signature of ugly crap!

It's covering my entire screen! No, it's crushing me! Get it off get it off!
you're falling through your subroutines. You're returning only under the condition of IF statements - ie., under certain conditions, such as the state of user input (which, by the way you only check once at the beginning of the program), you return if met, and keep right on executing if not met.

My recommendations:
* Use actual SUBs and FUNCTIONs instead of subroutines. It eliminates pesky errors like this
* Check user input every iteration of your main loop, and call your SUBs/FUNCTIONs based on that input - ie., right now you're calling every one of those subroutines regardless of whether the user wants to save/load, change color, etc.

@Z!re : damn woman, your post is polluting my screen. There is a pm feature on these forums, you know. You might want to use it (sorry, too lazy to use it myself. Do as I say, not as I do). Besides, there's no need to crap on the OP when he's asking for help. Not very nice.
This is a good new program, and you have learned much, but...

1) Ok, again, I told you this before..... but, you need to know what your program is doing. When you're doing "SAVE", you need to do a RETURN after it, like this: "SAVE: RETURN". Better yet, just put the RETURN at the end and don't put it after each IF statement.. if the answer is not Y or N, it will just end the program. You are not guaranteed to get a Y or N with an INPUT statement.

And, don't forget a SYSTEM or END at the END of your DO...LOOP. Smile

2) You don't have an I$ = INKEY$ in your loop!

3) Your X and Y limits are all wrong. They are all set to 51.. I can tell you didn't really finish that part, though.

4) I have no clue why, but in FB, CHR$(0) is replaced by CHR$(255)??

5) To save and load you can do many different things, including BLOAD and BSAVE, and using a sub from somewhere else to load/save in gifs, bmp's, jpg's, etc, or you can make your own routine..:
You should have a 2 dimensional array that records the color of each coordinate.. whenever you draw something in your screen, draw something to your array in that color, too. (Assign the value to the correct coordinate)


6) You can always use PAINT, you know..
i said i dont care about the actual box itself, i changed how it works and it works fine, its just the loop, i played around with it how i think i should but nothing, the box that is drawn in is now rite near the top left, ill change it so theres a zoomed in painting area later, but for, its just the damned loop, and saving in bmp form is alrite by me, later ill add a choice system to it where it adds the extension to the filemame, im only asking for help coding the loop and saving, loading, exiting, thats all, but if u wanna help wit the choices for the saving, then thats fine, ull get credit
I did...
well i tried using an if then before each gosub but no luck, im goin to try making each SUB a loop instead of just the main loop
Quote:@Z!re : damn woman, your post is polluting my screen. There is a pm feature on these forums, you know. You might want to use it (sorry, too lazy to use it myself. Do as I say, not as I do). Besides, there's no need to crap on the OP when he's asking for help. Not very nice.
Poop
Just try this.....

Code:
DEFINT A-Z
SCREEN 13

' The border of the drawing area
LINE (50, 50)-(67, 50), 15
LINE (67, 50)-(67, 67), 15
LINE (67, 67)-(50, 67), 15
LINE (50, 67)-(50, 50), 15

' The cursor
x% = 51
y% = 51
i$ = INKEY$
colour% = 0
PSET (1, 1), 15
DIM dot%(2)
GET (1, 1)-(1, 1), dot%
PSET (1, 1), 0
'cls
'put (5,5), dot%
'sleep
'system
' The almighty loop
DO
I$ = INKEY$
if I$ <> "" THEN
GOSUB cursor
GOSUB colourchoose
GOSUB drawpixel
GOSUB saveas
GOSUB loadas
GOSUB exitas
IF exitloop% = 1 THEN EXIT DO
END IF
LOOP
SLEEP
PRINT "Program has ended. Thanks for using.."

system


' SUB cursor

cursor:
PUT (x%, y%), dot%
IF i$ = CHR$(255) + "P" THEN y% = y% + 1
IF i$ = CHR$(255) + "H" THEN y% = y% - 1
IF i$ = CHR$(255) + "M" THEN x% = x% + 1
IF i$ = CHR$(255) + "K" THEN x% = x% - 1
PUT (x%, y%), dot%
IF x% < 51 THEN x% = 51
IF x% > 66 THEN x% = 66
IF y% < 51 THEN y% = 51
IF y% > 66 THEN y% = 66
RETURN

' SUB colorchoose
colourchoose:
IF i$ = "+" THEN colour% = colour% + 1
IF i$ = "-" THEN colour% = colour% - 1
IF colour% < 0 THEN colour% = 0
IF colour% > 255 THEN colour% = 255
' The current color box
LINE (69, 69)-(76, 69), colour%
LINE (76, 69)-(76, 76), colour%
LINE (76, 76)-(69, 76), colour%
LINE (69, 76)-(69, 69), colour%
PAINT (70, 70), colour%
' 1 pixel of selected color
PSET (1, 1), colour%
DIM pixel%(2)
GET (1, 1)-(1, 1), pixel%
PSET (1, 1), 0
RETURN

' SUB draw
drawpixel:
IF i$ = " " THEN PUT (x%, y%), pixel%
RETURN

' SUB save
saveas:
IF i$ = "s" OR i$ = "S" THEN INPUT "Are you sure you would like to SAVE? Y/N", response$
'IF response$ = "y" OR i$ = "Y" THEN SAVE
'IF response$ = "n" OR i$ = "N" THEN RETURN
return

' SUB load  
loadas:
IF i$ = "s" OR i$ = "S" THEN INPUT "Are you sure you would like to LOAD? Y/N", response$
'IF response$ = "y" OR i$ = "Y" THEN LOAD
'IF response$ = "n" OR i$ = "N" THEN RETURN
return

' SUB exit
exitas:
IF i$ = "x" OR i$ = "X" THEN INPUT "Are you sure you would like to EXIT? Y/N", response$
IF response$ = "y" OR i$ = "Y" THEN exitloop% = 1
'IF response$ = "n" OR i$ = "N" THEN RETURN
return
this is really starting to get complicated, i had a simple idea, and now its complicated, but i wont give up, i want to do this, i must complete this project, i must avenge... maybe thats a little too far
Pages: 1 2 3 4 5 6