Title: Hello World Post by: Dustie Bear on March 11, 2011, 08:10:08 pm I never have showed off my Hello World prog. So here it is. Do you have one to show off? ::) Code: a = _NEWIMAGE(800, 400, 32) SCREEN a, 2, 2 b = 255 FOR x = 0 TO 399 r = r + .5 b = b - .5 LINE (0, x)-(799, x), _RGB(r, 255, b) NEXT x LOCATE 1, 1 PRINT "Hello World" r = 257 b = -3 'LINE (1, 165)-(799, 256), _RGB(200, 200, 200), BF FOR x = 0 TO 86 r = r - 2: IF r < 0 THEN r = 0 g = 100 b = b + 3: IF b > 255 THEN b = 255 FOR y = 2 TO 11 IF POINT(x, y) = _RGB(255, 255, 255) THEN LINE (x * 7 + 15, y * 8 + 154)-(x * 7 + 21, y * 8 + 161), _RGB(r, g, b), BF END IF NEXT y NEXT x mypic = _NEWIMAGE(641, 112) _PUTIMAGE , 2, mypic, (1, 144)-(642, 256) 'LINE (1, 165)-(799, 254), _RGB(200, 200, 200), BF DO x = x - 1: IF x < -623 THEN x = 779 _PUTIMAGE (x, 144), mypic, 2 _DELAY .008 LOOP WHILE INKEY$ = "" _FREEIMAGE mypic SLEEP SYSTEM Title: Re: Hello World Post by: GarrisonRicketson on March 13, 2011, 03:19:56 pm This one is pretty nice,....
from Garry Title: Re: Hello World Post by: GarrisonRicketson on March 13, 2011, 05:46:15 pm Dusty, I still think yours is better,..but anyway, here is mine, a "crude" one.
I used some of what OldosLover has been trying to show me with _putimage. I think if more frames are used, one can get smoother better movements. The stick figure appears to move from side to side, which is intentional "danceing" anyway here it is. Code: REM Garrys Hello World You can use the attached image, this is a Demo, of a acceptable way to use this option.DEFLNG A-Z SCREEN 12 WorkPage& = _LOADIMAGE("helloworld.png") 'create the sprite sheet page _COPYPALETTE WorkPage&, 0 FrameNum& = 0 _DEST 0 LINE (50, 50)-(590, 430), 0, BF DO PLAY "mbaag12b5a8gg10adeg" FOR y = 0 TO 430 STEP 69 FOR x = 0 TO 635 STEP 91 _PUTIMAGE (1, 1)-(280, 234), WorkPage&, 0, (x, y)-(x + 89, y + 67) FrameNum& = FrameNum& + 1 _DELAY .25 LOCATE 22, 10: PRINT "HELLO WORLD" IF FrameNum& = 3 THEN GOTO 1 NEXT x NEXT y 1: FrameNum& = 0 LOOP WHILE INKEY$ = "" SLEEP 1 SCREEN WorkPage& 'show the sprite page SLEEP SYSTEM Title: Re: Hello World Post by: Dustie Bear on March 13, 2011, 05:54:09 pm Thats pretty slick Gary I like that and am looking at the ways you get the images from the Png file. individualy . thanks the music goes great with it too. Dustie Title: Re: Hello World Post by: GarrisonRicketson on March 13, 2011, 06:05:16 pm Ok ,thanks, OlDoslover has explained to me several times, a way to calculate
the size each frame should be, the image itself, is one image but divided into 3 frames, each frame has a image, if the image is not centered in the frame,it will appear to move from side to side a little, normally one dose not want that. For me this has been rather confuseing, but slowly I am getting it,..this was when we first started,....there is alot about _putimage in discussions,.. OlDosLover posted a good _putimage demo http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,30.0.html and also this can be disussed more, in these, http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/board,6.0.html I will be interesting to see what other "hello world" demos show up.... from Garry Title: Re: Hello World Post by: OlDosLover on March 13, 2011, 06:25:55 pm Hi all,
My first "Hello world" program i made worked well. My second "Hello World" program started to talk back in voices! So i stopped makeing "first contact" programs out of fear that aliens would contact me as i had basically invited them! OlDosLover. Title: Re: Hello World Post by: Cyperium on March 13, 2011, 07:31:14 pm Here's my little Hello World program :) it tries to resemble a sinus wave.
Code: DIM a$(11), x(11), y(11) 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) = k y(k) = 1 NEXT 1 CLS _LIMIT 30 round = round + .1 FOR k = 1 TO 11 x(k) = x(k) + 1 y(k) = y(k) + (COS(round + (k / 10)) / 2) + SIN(k / 1000) IF CINT(x(k)) + 25 > 80 THEN x(k) = -25 IF CINT(y(k)) + 12 > 23 THEN y(k) = -11 IF CINT(y(k)) + 12 < 0 THEN y(k) = 11 IF CINT(x(k)) + 25 > 0 AND CINT(x(k)) + 25 < 80 AND CINT(y(k)) + 12 > 0 AND CINT(y(k)) + 12 < 23 THEN LOCATE CINT(y(k)) + 12, CINT(x(k)) + 25: PRINT a$(k) NEXT _DISPLAY IF INKEY$ <> "" THEN END GOTO 1 Title: Re: Hello World Post by: OlDosLover on March 13, 2011, 07:38:37 pm Hi all,
Damn thats good Cy!. Pleased to have you onboard. Please post your QB64Help Viewer and other programs if you so wish. OlDosLover. Title: Re: Hello World Post by: Dustie Bear on March 13, 2011, 08:48:43 pm Thats realy neat Cyperium good job Dustie Title: Re: Hello World Post by: GarrisonRicketson on March 14, 2011, 09:13:34 pm Thanks CY,
Let us know when you are ready to release the helpfiles,...if you don't have the chance to put the download here, I will as soon as yu give the ok,.. from Garry Title: Re: Hello World Post by: Cyperium on March 15, 2011, 01:40:19 pm Thanks, I made it go in a circle :)
Code: DIM a$(11), x(11), y(11) 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 20 round = round + .1 'angle FOR k = 1 TO 11 x(k) = COS(round + (.1 * k)) * 20 '(.1 * k) gives the letter position in angle from the round angle y(k) = SIN(round + (.1 * k)) * 10 ' * 20, * 10 is the radius IF CINT(x(k)) + 25 > 80 THEN x(k) = -25 'wrapping if it goes outside screen boundary (this could behave wrong in the circle version though since I don't add x(k) to x(k) like in the sinus one) IF CINT(y(k)) + 12 > 23 THEN y(k) = -11 ' -..- IF CINT(y(k)) + 12 < 0 THEN y(k) = 11 ' -..- IF CINT(x(k)) + 25 > 0 AND CINT(x(k)) + 25 < 80 AND CINT(y(k)) + 12 > 0 AND CINT(y(k)) + 12 < 23 THEN LOCATE CINT(y(k)) + 12, CINT(x(k)) + 25: PRINT a$(k) 'display each character NEXT _DISPLAY IF INKEY$ <> "" THEN END GOTO 1 My help viewer isn't ready yet. I'm implementing selection right now (I've already implemented a cursor that you can move around and navigation through the keyboard (press A and it goes to the next link starting with A, SHIFT A goes to the next link that starts with _A so you can browse QB64 keywords as easily). I will probably release the final version in a few days or at this weekend. Any program of mine can be made public by anyone who wishes to do so (just don't take away my credit that I have in the source or other files, you are free to credit your own changes if you wish). Title: Re: Hello World Post by: GarrisonRicketson on March 15, 2011, 08:15:30 pm Ok CY, the circle hello world, kinda makes me dizzy!,..but it is neat,..
You can be sure, when you release the help viewer, I will always include credit, as to others, obviously thats out of our control,..but I think most people are pretty considerate about giveing credit, it is helpful when the programmer includes his name,etc in the source,.. thanks for posting this, from Garry Title: Re: Hello World Post by: Cyperium on March 16, 2011, 11:54:31 am Ok, thanks.
I made it a spiral! Code: 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 20 round = round + .1 '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 Title: Re: Hello World Post by: GarrisonRicketson on March 17, 2011, 07:12:00 pm CY ,
I get a subscript out of range line 12.--- Code: a$(11) = "d" But I can't figure out why ?Title: Re: Hello World Post by: Dustie Bear on March 17, 2011, 08:59:12 pm Thats realy neat Cyperium Dustie Title: Re: Hello World Post by: Cyperium 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! Title: Re: Hello World Post by: GarrisonRicketson 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 Title: Re: Hello World Post by: Cyperium 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) Use + to increase size, - to decrease size and ESC to end.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 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. Title: Re: Hello World Post by: GarrisonRicketson 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$ Now to other things, like just a image, or a straight block of text....but thats a different subject.IF kbd$ = "+" THEN size = size + .5 IF kbd$ = "-" THEN size = size - .5 IF kbd$ = CHR$(27) THEN END 'display the screen _DISPLAY from Garry Title: Re: Hello World Post by: Cyperium on March 27, 2011, 06:58:08 pm Thats pretty neat,...CY, Well, if you have any questions just ask. Where do you want to apply the keyboard code?I am going to try figure out also, how to apply this Code: kbd$ = INKEY$ Now to other things, like just a image, or a straight block of text....but thats a different subject.IF kbd$ = "+" THEN size = size + .5 IF kbd$ = "-" THEN size = size - .5 IF kbd$ = CHR$(27) THEN END 'display the screen _DISPLAY from Garry Remember that with _DISPLAY you don't need any PCOPY or anything for flicker-free CLS. Title: Re: Hello World Post by: GarrisonRicketson 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? Ok, I posted the question in a newtopic, in Lessons, because hereRemember that with _DISPLAY you don't need any PCOPY or anything for flicker-free 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 |