Weekly Qbasic and Qb64 Lesson Topics
October 24, 2017, 06:14:27 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 1070 times)
Dustie Bear
Full Member
***
Posts: 115


« 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?  Roll Eyes

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


Report Spam   Logged

Social Buttons

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: March 13, 2011, 03:19:56 pm »

This one is pretty nice,....
from Garry
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #2 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
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
 
You can use the attached image, this is a Demo, of a acceptable way to use this option.
Report Spam   Logged

Dustie Bear
Full Member
***
Posts: 115


« Reply #3 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
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #4 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
« Last Edit: March 13, 2011, 06:19:18 pm by GarrisonRicketson » Report Spam   Logged

OlDosLover
Guest
« Reply #5 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.
Report Spam   Logged
Cyperium
Newbie
*
Posts: 8


« Reply #6 on: March 13, 2011, 07:31:14 pm »

Here's my little Hello World program Smiley 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
« Last Edit: March 13, 2011, 07:33:16 pm by Cyperium » Report Spam   Logged
OlDosLover
Guest
« Reply #7 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.
Report Spam   Logged
Dustie Bear
Full Member
***
Posts: 115


« Reply #8 on: March 13, 2011, 08:48:43 pm »



  Thats realy neat Cyperium

good job

Dustie


Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #9 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
Report Spam   Logged

Cyperium
Newbie
*
Posts: 8


« Reply #10 on: March 15, 2011, 01:40:19 pm »

Thanks, I made it go in a circle Smiley

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).
« Last Edit: March 15, 2011, 01:47:53 pm by Cyperium » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #11 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
Report Spam   Logged

Cyperium
Newbie
*
Posts: 8


« Reply #12 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
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #13 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 ?
Report Spam   Logged

Dustie Bear
Full Member
***
Posts: 115


« Reply #14 on: March 17, 2011, 08:59:12 pm »


Thats realy neat Cyperium

Dustie
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