Weekly Qbasic and Qb64 Lesson Topics
July 22, 2018, 05:12:51 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  

Some of the first lessons,..


Pages: [1]
  Print  
Author Topic: Some of the first lessons,..  (Read 325 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: February 04, 2011, 10:34:25 pm »

These are some other older demos and lessons someone gave me, since they won't all fit in one post, I will keep adding them from time to time,
Here is one
Quote
Hi Garry
    You sent me this program.
-----------------------------------------------
REM AMV-Movie-1.bas
DEFLNG A-Z
'Does not show correct palette!
'This program can load any AMV file by changing
'1] File name
'2] Change "IF FrameNum& = 4 THEN GOTO 1" to the number of frames needed!
SCREEN 12 'must be started with this screen!


WorkPage& = _LOADIMAGE("c:\qb64Gary\Cgpx.bmp") 'create the sprite sheet page
_COPYPALETTE WorkPage&, 0 'this said invalid handle
FrameNum& = 0


_DEST 0
LINE (50, 50)-(590, 430), 6, BF


DO
    FOR Y = 0 TO 413 STEP 69
        FOR X = 0 TO 635 STEP 91
            '_PUTIMAGE (dx1,dy1)-(dx2,dy2), [source_handle], [dest_handle], (sx1,sy1)-(sx2,sy2)
            _PUTIMAGE (100, 100)-(480, 434), WorkPage&, 0, (X, Y)-(X + 89, Y + 67) 'this line also said invalid handel
            FrameNum& = FrameNum& + 1
            _DELAY .25
            LOCATE 22, 10: PRINT FrameNum&
            IF FrameNum& = 4 THEN GOTO 1
            PRINT "HELLO WORLD"
PLAY "MBaabgafeecgbd"
        NEXT X
    NEXT Y
    1:
    FrameNum& = 0
LOOP WHILE INKEY$ = ""


SLEEP 1
SCREEN WorkPage& 'show the sprite page
SLEEP
SYSTEM
------------------------------------------------------------
    Your pictures are displayed but not in correct color or in correct place on screen. Look at this version plz
------------------------------------------------------------
REM HelloWorld2
DEFLNG A-Z

SCREEN 12 'must be started with this screen!


WorkPage& = _LOADIMAGE("c:\qb64Gary\Cgpx1.bmp") 'create the sprite sheet page

_DEST 0
LINE (50, 50)-(590, 430), 6, BF


DO
    FOR x = 0 TO 479 STEP 120

        '_PUTIMAGE (dx1,dy1)-(dx2,dy2), [source_handle], [dest_handle], (sx1,sy1)-(sx2,sy2)
        _PUTIMAGE (100, 100)-(219, 189), WorkPage&, 0, (x, 0)-(x + 119, 89)
        _DELAY .5
        LOCATE 20, 10: PRINT x
        LOCATE 20, 30: PRINT x + 89
    NEXT x
    LOCATE 23, 3: PRINT "Notice colors are wrong!Is because image is 32bit on 16 color screen!"
LOOP WHILE INKEY$ = ""


SLEEP 1
SCREEN WorkPage& 'show the sprite page
SLEEP
SYSTEM
----------------------------------------------------------------------
   This program uses an edited bmp file. The difference between your bmp and mine is that
my one has the frames in a set pattern. How i did it i'll describe
1] open mspaint and set page to 480 pixel wide and 90 pixels high
2] draw black lines to indicate boundaries
3] open new mspaint ,load your bmp and copy your first frame into my instance of mspaint
4] i moved the image to centre it then i highlighted the entire 120 by 90 and copied it
into the other 3 blank frames.
5] i used the paint dropper to get the individual colors so i could redraw mans right arm
in a different place in last 3 frames
6] saved my version of your bmp to Cgpx1.bmp <-1

    In HelloWorld2 i removed all the unnecessary lines of code
Lets go through each line of code and i'll explain
DEFLNG A-Z = difine all variables using the starting letter A through to Z as LONG (&)
SCREEN 12 = set a display page of 640 by 480 pixels in 16 colors
WorkPage& = _LOADIMAGE("c:\qb64Gary\Cgpx1.bmp") 'load the sprite sheet page to our WorkPage&
_DEST 0 = point to place where we want stuff to go to (0 is a handle that means the output screen)
LINE (50, 50)-(590, 430), 6, BF = draw a box and fill it in with color 6

DO = start of loop
FOR x = 0 TO 479 STEP 120 = repeat a set amount of times

BUT HOW MANY TIMES?
120 multiplied by 4 = 480 or  480 divided by 120 = 4
So our image is 120 pixels wide x 4 = 480 (4 images side by side)
So where does the 0 and the 479 come from?
For some reason graphic screens ALWAYS reference the first pixel as ZERO (0)
So although ZERO means nothing in maths it is still a value and in this case the 1st value
So if ZERo is the 1st pixel the last pixel has to be 479
_PUTIMAGE (100, 100)-(219, 189), WorkPage&, 0, (x, 0)-(x + 119, 89) =
putimage(destination location),Where image is, Where image goes to , (source location)
        (100,100)-(219,189)                    (x,0)-(x+119,89)

   (219 -100 =119 )                    (x to x +119 =119,0 to 89 = 90)

On the first repeat x =0 so source location X1=0 where source location X2 =119
Thats equivalent to 120 pixel which is our images width and our first frame!
On next repeat x = 120 so source location X1=120 where source location X2 =x1 +119 (120 + 119 = 239)
Thats equivalent to 120 pixel which is our images width and our second frame!
On next repeat x = 240 so source location X1=240 where source location X2 =x1 +119 (240 + 119 = 359)
Thats equivalent to 120 pixel which is our images width and our third frame!
On next repeat x = 360 so source location X1=360 where source location X2 =x1 +119 (360 + 119 = 479)
Thats equivalent to 120 pixel which is our images width and our fourth frame!

The rest of the code you already know
-----------------------------------------------------
REM HelloWorld3
DEFLNG A-Z

SCREEN _NEWIMAGE(640, 480, 32) 'our new 32bit screen!

WorkPage& = _LOADIMAGE("c:\qb64Gary\Cgpx1.bmp") 'create + load the sprite sheet page

_DEST 0 'tell proggy to point to screen
Tint# = _RGB(255, 255, 0)  'set yellow color
'LINE (50, 50)-(590, 430), 6, BF '<---this wont work cause we need to use _RGB!
LINE (50, 50)-(590, 430), Tint#, BF

DO
    FOR x = 0 TO 479 STEP 120

        '_PUTIMAGE (dx1,dy1)-(dx2,dy2), [source_handle], [dest_handle], (sx1,sy1)-(sx2,sy2)
        _PUTIMAGE (100, 100)-(219, 189), WorkPage&, 0, (x, 0)-(x + 119, 89)
        _DELAY .5
        LOCATE 20, 10: PRINT x
        LOCATE 20, 30: PRINT x + 89
    NEXT x
    LOCATE 23, 3: PRINT "Notice colors are RIGHT!Is because image is 32bit on 32bit color screen!"
LOOP WHILE INKEY$ = ""


SLEEP 1
SCREEN WorkPage& 'show the sprite page
SLEEP
SYSTEM
-------------------------------------------------------
    The only difference in the third one is this
SCREEN _NEWIMAGE(640, 480, 32) 'our new 32bit screen!
Tint# = _RGB(255, 255, 0)  'set yellow color
LINE (50, 50)-(590, 430), Tint#, BF 'draw yellow box

Because you drew your original images in 32 bit color you have to use a 32 bit screen to display them
Becasue we using a 32bit screen we have to use _RGB and a color number. The color number is about
10 digits long!

 
You will need these :  Cgpx1.bmp and Cgpx.bmp, or you can make your own images, to work with.  This is the Link to dro box: http://dl.dropbox.com/u/15387474/Cgpx1.bmp
http://dl.dropbox.com/u/15387474/Cgpx.bmp
 On the first part I made many mistakes, and the author explains, how to do it better. Some thing I did not like is it looks like the arm is moveing in a circle, that may be a good project to learn, with...one could try. I think I did come up with one that looked better, but I will have to find it. From Garry
« Last Edit: September 11, 2011, 07:30:48 pm by GarrisonRicketson » Report Spam   Logged

Social Buttons

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



WWW
« Reply #1 on: September 11, 2011, 07:28:50 pm »

When I first started this forum, I was just starting to learn code, qbasic and qb64.
 So I had been asking questions, on qb64.net, petesqbasic site,..
  I also had my website http://www.garryspages.webs.com and have a fair amount of experience with html, ...
 Anway this guy offered to help,..it is a long story,..Unfortuately, it turned out he is mentaly ill ("disturbed"),..and this led to a real mess,..I feel sorry for him because I guess he can not help it. In a nut shell, what he started doing is whenever I did come up with some code that worked, or partially worked, the he would tell me I was all wrong, and modify it, posting new code, now the problem is now he claims he owns all the code on this forum, and this is not true, in any way, in fact alot of the code I did write, and most of the ideas that the code is based on were mine,..in the process of modifying and changeing code that I did write,..it is became clear to me, that is exactly what the guy was trying to do, make it appear, everything on the forum was his code,and only his,..I got onto it, when he started getting so mad when I wanted to also post and use code from other sources, besides him,..
to be continued,... Alot of what this guy wrote, is really not very good codeing examples, much dose not even work, so I am in the process of going thru it all, and removeing the useless stuff that dose not make sense, or work well, and keeping the original things that I thought of,..with what code I can understand and use,..nobody can claim they "own" any of it, includeing me, and anyone is free to copy and use any part or all, in anyway they wish.
 The guy has really caused a big mess, in this forum, and it will be a major task for me to "fix" it,...some of you may realize who I am talking about, but I am not going to bring up any names, or blame any one,..after all said and done it is my fault, because I am responsible for the forum, and I took so long to catch on to what the guy was doing. So I appologize to evryone for that.
Thank yu for your support.
from Garry
« Last Edit: September 11, 2011, 07:46:51 pm by GarrisonRicketson » Report Spam   Logged


Pages: [1]
  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
Privacy Policy