Fun programs with QBasic 4.5

Chat about just about anything else
rene
Level 11
Level 11
Posts: 3603
Joined: Sun Mar 27, 2016 6:58 pm

Re: Fun programs with QBasic 4.5

Post by rene » Sun Sep 01, 2019 12:27 pm

pascal111 wrote:
Sun Sep 01, 2019 11:56 am
I'll think in Python one day
I'll stop insisting after this but the main point I was trying to make was to not think in Python, or in BASIC, or in Pascal, or ..., but to focus on the structural logic common to all of them. To, that is, concentrate on (procedural) programming rather than on a specific language. If you'd know how many obsolete and at this point useless languages and workflows I once invested significant time in you'd understand the inclination to keep others from concentrating on BASIC in this day and age...

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Sun Sep 01, 2019 1:13 pm

I meant that I'm focusing on something in my mind but if I found a solution that's better than I've I'll use it, there's no problem against Python, the meaning is that I'm some familiar with BASIC logic and it's different than the C logic, so there's no problem to learn BASIC in this days if it's just to experience programming, there are many ways, some ways so modern, some others are not, but your purpose will decide how you go, if I'm planning to invade the programming market, this means BASIC isn't the good sensible choice for this age, you've another choices if you're Windows user or Linux one, depending on my knowledge, the Windows user who want to learn programming for the market purpose have to learn something like Visual Studio languages.

Another point, I see that many languages took C style, I've no direct objection, but we know at the time of DOS that the normal thing is to see many languages with many different attributes, there were at that time BASIC, C, Pascal, Cobol, Fortran ... etc, and each language has its own attributes, and you can see each language has programmers and not died, but now, depending on my knowledge, I've no real opinion about this period, you see good programs, good games, that means there's good programming, but when I'm searching in appropriate language for me I found that I've no clear or final answer. At DOS period, many thing are clear, for example, if I want to be so professional programmer for commercial programs and companies, I've to learn something like C++, if I know Pascal, I'm not bad one, but if I know QBasic, it doesn't has much programmers and I don't have clear idea about its programming abilities at that time, but I think at that time, you can be a QBasic programmer for some commercial programs.

You've sense in your words that we've to look in the period we live, for example, there's no sense if we found someone learning GW-BASIC in this days, maybe except for historical reason to know and experience how programming with such language was at its time. Maybe another one can say that he want to know about programming, its core without the additional tools we see in the modern languages, maybe there are another reasons.

I don't want to treat programming like movies for example, the new movies are showed only first in USA and after that they become to the world, so you'll notice that some parts of world are using old products that are not still usable in another more modern societies, but this will bring us to another important question that is there what can we describe as real old in programming world or they just techniques and tools, since C64 we are still using loops, conditions, variables, sub routines ... etc

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Mon Sep 02, 2019 5:40 am

This's a simple demo I made:

Main program:

Code: Select all

DECLARE FUNCTION spread$ (s$)
CLS

LOCATE 1, 25
PRINT "We say "; : COLOR 15: PRINT spread$("Hello");
COLOR 7: PRINT " to everyone"
LOCATE 2, 25
FOR i = 1 TO 28
PRINT "=";
NEXT i

LOCATE 23, 1
PRINT "Press ";
COLOR 15
PRINT spread("spacebar");
COLOR 7
PRINT " to stop!"
DO

LET k$ = "I love " + spread$("ghostrider1") + " movie :)"
LET row = INT(((19 + 1) - 1) * RND + 1)
LET column = INT((((80 - LEN(k$) + 1) + 1) - 1) * RND + 1)


LOCATE row + 3, column




COLOR 7
PRINT "I love ";
LET c = INT(((15 + 1) - 1) * RND + 1)
COLOR c
PRINT spread$("ghost");
LET c = INT(((15 + 1) - 1) * RND + 1)
COLOR c
PRINT " "; spread$("rider");
COLOR 4
PRINT " 1";
COLOR 7
PRINT " movie :)"


LOCATE row + 3, column
SLEEP 1
PRINT SPACE$(LEN(k$))

LOOP UNTIL INKEY$ = " "
END
Function:

Code: Select all

FUNCTION spread$ (s$)

LET a$ = RTRIM$(LTRIM$(s$))

FOR i = 1 TO LEN(a$)
LET b$ = b$ + (MID$(a$, i, 1)) + SPACE$(1)
NEXT i

LET b$ = RTRIM$(b$)
LET spread$ = UCASE$(b$)

END FUNCTION

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Wed Sep 04, 2019 1:19 pm

I read a tutorial that teach how to save an image to an array then how to use it again and put it by "PUT" command on the screen, I read too about "BSAVE/BLOAD" commands, to save and load an image to and from an image, so I modified the image I took from the tutorial to make two another forms of it and made this program to make an animation to fire image, I'm not good in graphics so I took made image and modified it., and this may not the standard way to make an animation with QB 4.5 but finally I made something I hoped before.

Program of loading the image from a file (the work without redrawing the original images again):

Code: Select all


DECLARE SUB drawing ()
OPTION BASE 1
REM $DYNAMIC
SCREEN 7, 0, 1, 0

DIM SHARED xlength, ylength
LET xlength = 9
LET ylength = 9
DIM fire(57 * 3) AS INTEGER

CALL drawing
GET (0, 0)-(xlength, ylength), fire(1)
CLS
CALL drawing
GET (0, 0)-(xlength, ylength), fire(58)
CLS
CALL drawing
GET (0, 0)-(xlength, ylength), fire(115)
CLS

DEF SEG = VARSEG(fire(1))
BSAVE "fimage.bmp", VARPTR(fire(1)), 342
DEF SEG
'ERASE fire
'REDIM fire(57 * 3)
'DEF SEG = VARSEG(fire(1))
'BLOAD "fimage.bmp", VARPTR(fire(1))
'DEF SEG

FOR i = 1 TO 10
PUT (100, 100), fire(1)
PCOPY 1, 0
FOR h = 1 TO 6000: NEXT h
CLS

PUT (100, 100), fire(115)
PCOPY 1, 0
FOR h = 1 TO 6000: NEXT h
CLS

PUT (100, 100), fire(58)
PCOPY 1, 0
FOR h = 1 TO 6000: NEXT h
CLS

NEXT i


REM *** First form of flames
first:
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,04,00,00,00,00,00,00
DATA 00,00,04,04,04,00,00,00,00,00
DATA 00,04,04,04,04,04,00,00,00,00
DATA 00,04,04,12,04,04,04,00,00,00
DATA 00,04,04,12,12,04,04,00,00,00
DATA 00,04,12,12,12,04,04,04,00,00
DATA 00,04,12,12,14,12,04,04,00,00
DATA 00,04,12,12,14,14,12,04,00,00
DATA 00,04,12,14,14,12,12,04,00,00

second:
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,04,04,04,04,04,04,00,00
DATA 00,00,04,04,12,04,04,04,00,00
DATA 00,04,04,12,12,12,04,00,00,00
DATA 00,04,04,12,12,04,04,00,00,00
DATA 00,04,12,12,12,04,04,00,00,00
DATA 00,04,12,14,12,12,04,00,00,00
DATA 04,04,12,14,14,14,12,00,00,00
DATA 04,04,12,14,14,14,12,04,00,00

third:
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,04,00,04,00,00,00,00
DATA 00,00,04,04,04,04,00,00,00,00
DATA 00,00,04,12,12,04,04,00,00,00
DATA 00,00,12,12,12,04,04,00,00,00
DATA 00,00,12,14,12,12,04,00,00,00
DATA 00,00,12,14,14,12,12,00,00,00
DATA 00,00,12,14,14,12,12,00,00,00

Sub routine:

Code: Select all

REM $STATIC
SUB drawing
FOR y = 0 TO 9
FOR x = 0 TO 9
READ c
PSET (x, y), c
NEXT x
NEXT y
END SUB
After saving the image, you can hide the effect of saving commands by remark signs and remove these signs from the commands of loading, you can make seperate program for that and use the same file, remember too to determine the current path that QBasic will save the image file in, you can do that from "DOS Shell" in "File" menu.

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Fri Sep 06, 2019 7:39 am

I succeeded to use Plus Pixel 256 graphics editor to make images and load it by QBasic, it's beautiful experience, I found difficulties in the beginning to understand how the editor work appropriately to make correct image size to be able to download it fine with QBasic, I made an image file that have the English alphabet and made a program that has a function to convert normal character strings to that graphical alphabet.


Image

The image file and be sure of the path when you use QBasic:
https://gofile.io/?c=nlbFdK

Main program:

Code: Select all

DECLARE SUB ecris (s$)
REM $DYNAMIC
SCREEN 13
OPTION BASE 1

DIM SHARED alphab(130, 26) AS INTEGER
DIM SHARED x, y

DEF SEG = VARSEG(alphab(1, 1))
BLOAD "letters.put", alphab(1, 1)
DEF SEG

LET x = 0
LET y = 0

CALL ecris("bonjour o le monde")
LET y = y + 16
LET x = 0
CALL ecris("Is this magic what a beautiful art")
LET y = y + 16
LET x = 0
CALL ecris("I made this alphabet myself I can not beleive it")
Sub routine:

Code: Select all

REM $STATIC
SUB ecris (s$)
FOR i = 1 TO LEN(s$)
LET x$ = UCASE$(MID$(s$, i, 1))
IF y = 200 THEN EXIT SUB
IF x = 320 THEN
LET y = y + 16
LET x = 0
END IF

IF x$ = " " THEN GOTO jump
LET ch = ASC(x$) - 64
PUT (x, y), alphab(1, ch)
jump:
LET x = x + 16
NEXT i
END SUB
EDIT: I added an image.

Post Reply

Return to “Open chat”