QB64.org Forum
Active Forums => Programs => Topic started by: SierraKen on August 28, 2020, 10:01:23 pm
-
I'm extremely close to finishing this program but I am at my usual standstill with the _PUTIMAGE and _COPYIMAGE commands it's driving me nuts again. Can someone tell me why this isn't working? When I press the left mouse button it's supposed to place the shape onto the screen so someone can make a new shape for the same screen. Of course CLS clears it in every loop but it should still work with COPYIMAGE and PUTIMAGE and DISPLAY. Read the _TITLE for instructions on how to use it. The amazing thing is, I was just experimenting with my other shapes maker and I added a loop and here's 3D. :) So I added depth changes, rotation, size changes, and location with the mouse. The main loop starts at line 103. I'm also wondering if I have to use 2 NEWIMAGE's like I have here, would CLIPBOARDIMAGE still work when it can only do one image? Any help is appreciated, thanks.
start:
sides = 3
length = 150
full = 0
c = 0
_TITLE "Mouse To Locate, Mouse Wheel To Change Sides, C To Copy To Clipboard, +/- To Change Size, Arrow Keys To Change Depth And Rotate."
PRINT " By SierraKen (with some help from B+!)" full:
INPUT "Select Color Emptiness (1-50 Where 50 Being Most Empty.)", full
full = full / 10
colors:
c = c + 1
'Color Wheel
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = 0
mouseLeftButton = 0
mouseWheel = 0
IF mouseLeftButton
= -1 AND c
= 1 THEN mouseLeftButton
= 0: col&
= POINT(mouseX
, mouseY
):
GOTO colors:
IF mouseLeftButton
= -1 AND c
= 2 THEN mouseLeftButton
= 0: backcol&
= POINT(mouseX
, mouseY
):
GOTO nex:
'Create Shape
nex:
mouseWheel = 0
IF a$
= "+" THEN length
= length
+ 1 IF a$
= "-" THEN length
= length
- 1 IF length
> 800 THEN length
= 800 IF mouseWheel
= -1 THEN sides
= sides
+ 1 IF mouseWheel
= 1 THEN sides
= sides
- 1
FOR angle
= 1 + a
TO 360 + a
STEP 360 / sides
oldx = x
oldy = y
x
= (COS(_D2R(angle
)) * length
) + mouseX
y
= (SIN(_D2R(angle
)) * length
) + mouseY
LINE (x
- t
, y
- t
)-(oldx
- t
, oldy
- t
), col&
-
Like this?
start:
sides = 3
length = 150
full = 0
c = 0
_TITLE "Mouse To Locate, Mouse Wheel To Change Sides, C To Copy To Clipboard, +/- To Change Size, Arrow Keys To Change Depth And Rotate."
PRINT " By SierraKen (with some help from B+!)" full:
INPUT "Select Color Emptiness (1-50 Where 50 Being Most Empty.)", full
full = full / 10
colors:
c = c + 1
'Color Wheel
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = 0
mouseLeftButton = 0
mouseWheel = 0
IF mouseLeftButton
= -1 AND c
= 1 THEN mouseLeftButton
= 0: col&
= POINT(mouseX
, mouseY
):
GOTO colors:
IF mouseLeftButton
= -1 AND c
= 2 THEN mouseLeftButton
= 0: backcol&
= POINT(mouseX
, mouseY
):
GOTO nex:
'Create Shape
nex:
mouseWheel = 0
IF a$
= "+" THEN length
= length
+ 1 IF a$
= "-" THEN length
= length
- 1 IF length
> 800 THEN length
= 800 IF mouseWheel
= -1 THEN sides
= sides
+ 1 IF mouseWheel
= 1 THEN sides
= sides
- 1
FOR angle
= 1 + a
TO 360 + a
STEP 360 / sides
oldx = x
oldy = y
x
= (COS(_D2R(angle
)) * length
) + mouseX
y
= (SIN(_D2R(angle
)) * length
) + mouseY
LINE (x
- t
, y
- t
)-(oldx
- t
, oldy
- t
), col&
I am impressed how you figured to rotate the sides!
-
Thanks Tons B+! :)). I did notice that the background color was gone, so I fixed it. Yeah rotating the polygons were actually pretty easy if you just add to the angle up to 360 and then shift back to 0 and the other way around. :) I used your code from earlier on my other shapes program for the COS and SIN equations. There one MINOR thing that would be nice on this program is if when you press C to copy the image to the buffer, it doesn't copy the current polygon that's being moved around with the mouse. I think that would have to deal with another COPYIMAGE or something and since you have helped me this far, I'm not going to try and make it worse by me. LOL People can just use the last polygon as part of their image. Thanks again B+, I see what you did with PUTIMAGE on the mouse click. This will be a good learning example for my future works.
start:
sides = 3
length = 150
full = 0
c = 0
_TITLE "Mouse To Locate, Mouse Wheel To Change Sides, C To Copy To Clipboard, +/- To Change Size, Arrow Keys To Change Depth And Rotate."
PRINT " By SierraKen (with some help from B+!)" full:
INPUT "Select Color Emptiness (1-50 Where 50 Being Most Empty.)", full
full = full / 10
colors:
c = c + 1
'Color Wheel
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = 0
mouseLeftButton = 0
mouseWheel = 0
IF mouseLeftButton
= -1 AND c
= 1 THEN mouseLeftButton
= 0: col&
= POINT(mouseX
, mouseY
):
GOTO colors:
IF mouseLeftButton
= -1 AND c
= 2 THEN mouseLeftButton
= 0: backcol&
= POINT(mouseX
, mouseY
):
GOTO nex:
'Create Shape
nex:
mouseLeftButton = 0
mouseWheel = 0
IF a$
= "+" THEN length
= length
+ 1 IF a$
= "-" THEN length
= length
- 1 IF length
> 800 THEN length
= 800 IF mouseWheel
= -1 THEN sides
= sides
+ 1 IF mouseWheel
= 1 THEN sides
= sides
- 1
FOR angle
= 1 + a
TO 360 + a
STEP 360 / sides
oldx = x
oldy = y
x
= (COS(_D2R(angle
)) * length
) + mouseX
y
= (SIN(_D2R(angle
)) * length
) + mouseY
LINE (x
- t
, y
- t
)-(oldx
- t
, oldy
- t
), col&
-
If you want the image without the current polygon, you already have it stored in image2&. That is what is being put up on screen before each redraw of current poly.
-
ROFL AWESOME!!! Thanks :).
Here is the update and a picture of 2 houses I made with it in just a couple minutes.
start:
sides = 3
length = 150
full = 0
c = 0
_TITLE "Mouse To Locate, Mouse Wheel To Change Sides, C To Copy To Clipboard, +/- To Change Size, Arrow Keys To Change Depth And Rotate."
PRINT " By SierraKen (with some help from B+!)" full:
INPUT "Select Color Emptiness (1-50 Where 50 Being Most Empty.)", full
full = full / 10
colors:
c = c + 1
'Color Wheel
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = sz + .2
sz = 0
mouseLeftButton = 0
mouseWheel = 0
IF mouseLeftButton
= -1 AND c
= 1 THEN mouseLeftButton
= 0: col&
= POINT(mouseX
, mouseY
):
GOTO colors:
IF mouseLeftButton
= -1 AND c
= 2 THEN mouseLeftButton
= 0: backcol&
= POINT(mouseX
, mouseY
):
GOTO nex:
'Create Shape
nex:
mouseLeftButton = 0
mouseWheel = 0
IF a$
= "+" THEN length
= length
+ 1 IF a$
= "-" THEN length
= length
- 1 IF length
> 800 THEN length
= 800 IF mouseWheel
= -1 THEN sides
= sides
+ 1 IF mouseWheel
= 1 THEN sides
= sides
- 1
FOR angle
= 1 + a
TO 360 + a
STEP 360 / sides
oldx = x
oldy = y
x
= (COS(_D2R(angle
)) * length
) + mouseX
y
= (SIN(_D2R(angle
)) * length
) + mouseY
LINE (x
- t
, y
- t
)-(oldx
- t
, oldy
- t
), col&
-
It also can do (mostly) filled-in polygons too. When you start it, you give a value up to 50, 50 being the most emptiness. Here is what it looks like with selecting 1 instead of 50.