Weekly Qbasic and Qb64 Lesson Topics
April 25, 2018, 05:25:29 am
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Hello World


Pages: 1 [2]
  Print  
Author Topic: Hello World  (Read 1081 times)
Cyperium
Newbie
*
Posts: 8


« Reply #15 on: March 20, 2011, 03:14:14 pm »

Yes, Garrison, sorry about that, it's fixed here:

Code:
DIM a$(11), x(11), y(11)
SCREEN _NEWIMAGE(640, 480, 13)
a$(1) = "H"
a$(2) = "e"
a$(3) = "l"
a$(4) = "l"
a$(5) = "o"
a$(6) = " "
a$(7) = "W"
a$(8) = "o"
a$(9) = "r"
a$(10) = "l"
a$(11) = "d"
FOR k = 1 TO 11
    x(k) = 1 'they should differ by angles and radius only
    y(k) = 1 'they should differ by angles and radius only
NEXT




1
CLS
_LIMIT 100
round = round + .02 'angle
FOR k = 1 TO 11

    x(k) = COS(round + (.5 * k)) * k * 10 '       (.5 * k) gives the letter position in angle from the round angle
    y(k) = SIN(round + (.5 * k)) * k * 10 '       k * 10 is the radius (progressing inward to out using k in steps of 10).

    _PRINTSTRING (x(k) + 320, y(k) + 240), a$(k) 'display each character

NEXT


_DISPLAY

IF INKEY$ <> "" THEN END
GOTO 1


For some reason I didn't copy the first line where the DIM took place. I took the liberty of making it smoother as well so it's easier for the eyes! To get the ordinary circle just remove the * k in the radius equation (* k * 10 becomes * 10) and change * 10 to * 100. To get a line of characters from the center remove the * k in the angle equation (.5 * k becomes .5) and make sure the radius equation is * 10, you could also remove the entire (.5 * k) equation for the same effect.

Thanks, Dustie Bear!
« Last Edit: March 20, 2011, 03:34:32 pm by Cyperium » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #16 on: March 20, 2011, 08:43:34 pm »

Ok, now it works, I wonder, how would one make the letters bigger, Is that possible ?
from Garry
Report Spam   Logged

Cyperium
Newbie
*
Posts: 8


« Reply #17 on: March 24, 2011, 07:41:27 pm »

I guess that you could make each letter images and use _PUTIMAGE to make them bigger then use the same principle as with the letters. I'll give it a try:


Code:
DIM a$(11), x(11), y(11), image(11)
scrhandle = _NEWIMAGE(640, 480, 13)
SCREEN scrhandle
a$(1) = "H"
a$(2) = "e"
a$(3) = "l"
a$(4) = "l"
a$(5) = "o"
a$(6) = " "
a$(7) = "W"
a$(8) = "o"
a$(9) = "r"
a$(10) = "l"
a$(11) = "d"
FOR k = 1 TO 11
    x(k) = 1 'they should differ by angles and radius only
    y(k) = 1 'they should differ by angles and radius only
NEXT

FOR im = 1 TO 11
    image(im) = _NEWIMAGE(8, 10, 13) 'make a new image the same size as the letter
    _DEST image(im) 'make image(im) the destination image (for drawing)
    _PRINTSTRING (0, 0), a$(im) 'print the letter to the image
NEXT
_DEST scrhandle 'make scrhandle the destination image to draw on (scrhandle is set as the SCREEN)

size = 2 'set default size (double the size)

1
CLS
_LIMIT 100
round = round + .02 'angle
FOR k = 1 TO 11

    x(k) = COS(round + (.5 * k)) * k * 10 * size '       (.5 * k) gives the letter position in angle from the round angle
    y(k) = SIN(round + (.5 * k)) * k * 10 * size '       k * 10 is the radius (progressing inward to out using k in steps of 10).
    '                                                    * size is to adjust the radius according to the new size.
    _PUTIMAGE (x(k) + 320, y(k) + 240)-(x(k) + 320 + (8 * size), y(k) + 240 + (10 * size)), image(k), scrhandle, (0, 0)-(8, 10)
    '                                     destination coordinates (*size)                    source  destination  source coordinates
NEXT
'handles keyboard input:
kbd$ = INKEY$
IF kbd$ = "+" THEN size = size + .5
IF kbd$ = "-" THEN size = size - .5
IF kbd$ = CHR$(27) THEN END
'display the screen
_DISPLAY


GOTO 1


Use + to increase size, - to decrease size and ESC to end.

There are other ways of achieving this, but I wanted to avoid treating the pixels individually. Right now I treat the letters as images instead.
« Last Edit: March 24, 2011, 07:57:59 pm by Cyperium » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #18 on: March 24, 2011, 09:57:02 pm »

Thats pretty neat,...CY,
I am going to try figure out also, how to apply this
Code:
kbd$ = INKEY$
IF kbd$ = "+" THEN size = size + .5
IF kbd$ = "-" THEN size = size - .5
IF kbd$ = CHR$(27) THEN END
'display the screen
_DISPLAY     
Now to other things, like just a image, or a straight block of text....but thats a different subject.
from Garry
Report Spam   Logged

Cyperium
Newbie
*
Posts: 8


« Reply #19 on: March 27, 2011, 06:58:08 pm »

Thats pretty neat,...CY,
I am going to try figure out also, how to apply this
Code:
kbd$ = INKEY$
IF kbd$ = "+" THEN size = size + .5
IF kbd$ = "-" THEN size = size - .5
IF kbd$ = CHR$(27) THEN END
'display the screen
_DISPLAY     
Now to other things, like just a image, or a straight block of text....but thats a different subject.
from Garry
Well, if you have any questions just ask. Where do you want to apply the keyboard code?

Remember that with _DISPLAY you don't need any PCOPY or anything for flicker-free CLS.
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #20 on: March 27, 2011, 07:26:22 pm »

Quote
  Well, if you have any questions just ask. Where do you want to apply the keyboard code?

Remember that with _DISPLAY you don't need any PCOPY or anything for flicker-free 
Ok,  I posted the question in a newtopic, in Lessons, because here
was intended for real DEMOS, sort of trying to keep it organized
so please go to this topic, where I explain, where and how I want to apply this:
http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,110.0.html
I appreciate it, thanks
from Garry
« Last Edit: March 27, 2011, 07:46:33 pm by GarrisonRicketson » Report Spam   Logged


Pages: 1 [2]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines