Title: NEW LESSON, KBD commands (keyboard) Post by: GarrisonRicketson on March 27, 2011, 07:41:48 pm Code: kbd$ = INKEY$ My question would be, for example, but this did not work... I would just say PRINT "THIS LINE OR HELLO WORLD" I suppose also it should include LOCATE, to place the text in the middle of the screen, Code: PRINT "use the + key to make the text bigger, - key to make it smaller" Like I said I tried it like this but this is not correct....no luck. So if yu can explain ? Thanks from Garry Title: Re: NEW LESSON, KBD commands (keyboard) Post by: Dustie Bear on March 27, 2011, 11:14:41 pm If your asking how to keep the program from ending after hitting a
key, this will work. Code: PRINT "use the + key to make the text bigger, - key to make it smaller" Title: Re: NEW LESSON, KBD commands (keyboard) Post by: GarrisonRicketson on March 28, 2011, 12:36:17 am Thanks Dusty,
But, that was only part, of the problem, Code: kbd$ = INKEY$ Your code dose keep it from exiting though, I notice you put in 'call sub to change sizes, as a remark,...but there is no sub, dose this meand I need to make a sub, to change the sizes,...Ahh,...now I am thinking, but I still do not see how to do it,..almost, I may need to use DIM, on the text, then a sub, with the _putimage, and kbd$ . Don't know, and it is pretty late, maybe tommorow I can fool around with this some more,... thanks though,...at least that part of it I understand now, keeping it from exiting... from Garry Title: Re: NEW LESSON, KBD commands (keyboard) Post by: OlDosLover on March 28, 2011, 08:28:31 am Hi all,
One way to do it is to create a screen that the user see's permanently like SCREEN _newimage(800,600,32) .<-- this creats it and makes it the active screen. To make text that can be resized make another "hidden" screen where you print out that text. It "hidden" because you never actually see this screen, it exists in memory only. It doesnt matter how big or small the hidden window is. Hidden& = _newimage(200,100,32) '<-- very small screen Now as the user already has a window he can view , thats where the output will appear (destination). So we have to make the smaller hidden window the source. So we print on this window some text like "Hello World" So once we have directed QB64 to print our message to our small screen , we need to point back to the big screen. Why? At the moment every command that interacts with the screen(print,circle,line,etc) will do so on the small screen unless we point back to the screen we want this interaction to appear on. Use the keypad PLUS and MINUS keys to change size. Note how i used _putimage in this example. There are NO source co-ordinates which means the entire window(small hidden one) is referenced. What we do is change the destination co-ordinates. This means that the place on the big screen grows and shrinks even thought we place the same size of the small screen into this growing or shrinking place. Putimage scales it for us! Code: REM More to be added OlDosLover. Title: Re: NEW LESSON, KBD commands (keyboard) Post by: Dustie Bear on March 28, 2011, 09:19:18 am hi
Quote dose this meand I need to make a sub, to change the sizes Im modifying my message. You can use a sub if ya want but due to amount of code its not neccessary, that code OldDos put up is very easy to follow and understand without breaking it up into smaller sections (subs etc ) after your program gets larger you might want to use a sub. Dustie Title: Re: NEW LESSON, KBD commands (keyboard) Post by: OlDosLover on March 28, 2011, 10:10:31 am Hi all,
I think Dustie can rewrite my rather simple example to demonstrate subs. I believe that we all learn better from more teachers and examples than 1. OlDosLover. Title: Re: NEW LESSON, KBD commands (keyboard) Post by: Dustie Bear on March 28, 2011, 11:48:14 am Old Dos, Your doing fine, Yes I did mention using a sub but the program at this point he probably doesnt realy need one. Once he gets the text size thing figured out, no doubt he will want to start rotating it. then it would be a good time to start segragating some parts into subs for clarity. The program will be getting larger so breaking it up into smaller sections would be easier to play with it. Only reason I suggest using subs is that it makes it easier to break down certain parts of a program into smaller parts so its easier modify and understand what each section does. When I write a realy large programs like my weather chart program. Once certain parts are trouble shooted and working fine I actualy forget how those parts of the program even worked! even though the rest of the program is still being written. Dont know how to explain that. I guess it is like using the print statement or some other command. we use them but dont realy know how they were coded or even work in some cases. Thats how some of my subs end up. I don't recall how I wrote them or how they worked even. lol I just expect them to be there as I add code which may refer to them. I guess using commands from librarys could be an example, as long as we know what that command does in some cases we probably dont realy care how it does it. Dustie Title: Re: NEW LESSON, KBD commands (keyboard) Post by: OlDosLover on March 28, 2011, 11:56:47 am Hi all,
I agree and you are correct. I'd like colaboration on this topic that illustrates all sorts ways to do the program. The end user selects the method that they relate to and learn quicker in my opinion. OlDosLover. Title: Re: NEW LESSON, KBD commands (keyboard) Post by: Dustie Bear on March 28, 2011, 12:58:13 pm Sorry after looking at my hello world its not how you are doing this
I removed the animations and fancey colors from it so you could see how I was enlarging it.Im posting it anyway just for interest sake. Do to the amount of variables involved its not very handy for what you are doing but its something to get ideas from for future . Code: a = _NEWIMAGE(800, 400, 32) Dustie Title: Re: NEW LESSON, KBD commands (keyboard) Post by: Cyperium on March 28, 2011, 05:41:03 pm size is just a variable, not a sub, like in OlDosLover's example the size variable can be used in _PUTIMAGE to increase the size of the destination area (the source area will fit the destination area, so making the destination area bigger than the source area will increase the size of the image put).
I know the above seemed complicated, this is just because words can't describe it better, examples can though. Let's break down _PUTIMAGE so we know what each part does: This is the destination part of _PUTIMAGE it tells where to put the image: _PUTIMAGE (xdestination, ydestination)-(xdestination2, ydestination2) The xdestination variables forms a area in which the image will fit. If the image doesn't fit then the image size is increased or decreased in order to fit. The source part of _PUTIMAGE tells us what part of the image to put in the destination (sourceimage is the image handle of the source and destinationimage is the image handle of the destination): _PUTIMAGE (xdestination, ydestination)-(xdestination2, ydestination2),sourceimage,destinationimage, (xsource,ysource)-(xsource2,ysource2) If the source area (xsource,ysource)-(xsource2,ysource2) is smaller than the destination area then the image will increase its size to fit the destination area. In the source area you should always define the area that you want to display in the destination image. kbd$ is also just a variable, it is made to hold the contents of the INKEY$ function (which is a string representing the key entered on the keyboard). I'll come up with some more examples covering this later. In the meantime feel free to ask about all this :) Title: Re: NEW LESSON, KBD commands (keyboard) Post by: GarrisonRicketson on March 28, 2011, 09:41:47 pm Thank you, all, on this,...the code Oldoslover posted works pretty much like what I had in mind, and makes sense, I see the relatiions, hidden$ ,_NEWIMAGE,
_DEST hidden$ and then that hidden$ is at the end of the _putimage statement,.. so I think I see how it all ties together, and how Screen _newimage establishes a screen, to put everything on. I added some lines of text, and had to make some small changes, to do that, also added instructions,... Quote Once he gets the text size thing figured out, no doubt he will want to , actually, for text no, all though interesting idea, but I can't read to well upside down, or side ways, how ever, a image, yes,...but later, start rotating it My thoughts now, are to use a DATA map, for the image, but I am not sure, just "playing around with this", I don't have any plan, it is because when I first saw CY make the letters bigger, in his "hello world" spiral, that cuaght my interest, the variable knd$ Quote kbd$ is also just a variable, it is made to hold the contents of the INKEY$ function (which is a string representing the key entered on the keyboard). This seems to have a lot of uses, changeing size, moveing, jumping ?,...probabley more,I just have not yet thought of.Here is the changes I made, Code: REM Code: xx = 7 ' set size of enlarged pixels Thanks again everyone. from Garry Title: Re: NEW LESSON, KBD commands (keyboard) Post by: GarrisonRicketson on April 04, 2011, 10:07:44 pm Code: REM Code: DECLARE SUB PUT2 (Sprite() AS INTEGER, XSize AS INTEGER, YSize AS INTEGER, X AS INTEGER, Y AS INTEGER) thanks from Garry Title: Re: NEW LESSON, KBD commands (keyboard) Post by: OlDosLover on April 05, 2011, 07:03:03 am Hi all,
Garry you got most of it right!. We have to read the data and place it on the hidden screen. From the hidden screen it is scaled up or down as in the above example. Your experimental program tries to use the "PUT" command. GET can capture a part of ANY screen (point to that screen with _dest NameofScreen) and once housed inside an array then it can be PUT to another screen. The line Quote DECLARE SUB PUT2 (Sprite() AS INTEGER, XSize AS INTEGER, YSize AS INTEGER, X AS INTEGER, Y AS INTEGER) i believe is from the GDK. QB64 doesnt need declarations and ignores them. Did you want this illustrated by using the GDK ?Code: REM OlDosLover. Title: Re: NEW LESSON, KBD commands (keyboard) Post by: GarrisonRicketson on April 05, 2011, 07:53:23 am Quote DECLARE SUB PUT2 (Sprite() AS INTEGER, XSize AS INTEGER, YSize AS INTEGER, X AS INTEGER, Y AS INTEGER) Actually that was part of the code in tut for qb64,...I had not thought about it, If you have time, and feel like like it though, that would be interesting to see, it useing GDK, I guess though it would be best if we start that in the GDK, categorys,.. I don't have much time right now, have to get ready for work, but thanks, I think I see what you did here, though,... thanks from Garry |