Weekly Qbasic and Qb64 Lesson Topics
October 20, 2018, 06:57:59 pm
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  

Opens Notepad,but need to know more


Pages: 1 [2]
  Print  
Author Topic: Opens Notepad,but need to know more  (Read 1218 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #15 on: April 29, 2011, 07:06:36 am »

Ok that sound good, I was just trying this out a little,before I go to work,...
But it will still be later when I have any real question or comment,...but basicly it it
is a step n the right direction, and seems to work,ok
From Garry
Report Spam   Logged

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



WWW
« Reply #16 on: May 03, 2011, 10:45:06 pm »

I finally got to doing more with this, and that works good, I've got some ideas I would like to try, because, I still would like to also have the image change, with each line of new text, a new image,..My thought is to make a spritesheet, lets say 4 images, to start,..they will be 4 persons(characters), names, Jim, Bob,George,Joe ( this is just a simple, "sketch",or outline). The text is also 4 lines
1st image is JIM, text= hello this is jim
then on the key press, next image is Bob, txt=hello this is bob,...and so on. With the image, and sprite sheet
Code:
   DO
  FOR x = 0 TO 261 STEP 67
    _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
    _DELAY .08
  NEXT        
So at least I think, this is where the adjustment would need to be made, instead of running the 4 frames, like a animation, it moves to the next frame, with each key press,....along with the txt..Hmm,..Do I make sense,? besides the fact one might wonder, it may seem like a silly idea,...but not really, being for example for a child or even a adult, trying to learn to read, or also learn english/spanish. The image, shows, with the text IE:
Image = a coffecup,   text = CUP / TAZA,...Image of a horse, text = HORSE/Caballo
 OK , then eventually, this could evolve, even more complex, with some input options,  the image shows,..and the user has to enter the name of it, correctly spelled, in either language they are trying to learn/write, but that would be later, I guess, Here is a good question, Since I already know I will eventually want to add user input, like entering the correct name,and spelling it corectly,.. is it better,or easier, to start setting that up too, at the beginning ? or can it be worked in later, just as easily, Ie: without haveing to go back and start changeing everything that I (we) had so far ?
 What I am trying to say, I realize with a game, it is best to have a good outline, of what the game will be , the plot, so to speak,...the same I imagen applys to a program, such as a reading or math, or well I guess any program really,...I guess this should be about it for now,
Quote
Perhaps its time we did some tuts on files generally. What do you think?  
Yes this sounds good, also I realize, a lot in the, filtered input routines,
http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,145.0.html
 will apply here, too.
 Anyway I hope this is makeing sense, it dose to me, but I allready know what I am thinking, the hard part is explaining in a way that others can understand,.....Heee!
from Garry
Tommorrow, (I hope), I will post a 4 frame spritesheet, with some "stickcharacters", Bob Jim, george and joe,....I guess it could be the ghosts too, inky ,blinky, and i dont remember the others....that dose not matter much, the code that syncronizes, the text with each frame is what matters,..
from Garry
« Last Edit: May 03, 2011, 10:52:08 pm by GarrisonRicketson » Report Spam   Logged

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



WWW
« Reply #17 on: May 10, 2011, 08:10:03 pm »


Quote
Tommorrow, (I hope), I will post a 4 frame spritesheet, with some "stickcharacters", Bob Jim, george and joe,....I guess it could be the ghosts too, inky ,blinky, and i dont remember the others....that dose not matter much, the code that syncronizes, the text with each frame is what matters,..

[/quote]
POR FIN(FINALY)----
Here are the "stick figures", I used your qb64_paint18, to draw them,...Unseens sprite sheet maker,..to do the sprite sheet,..so it should be ok,...I has been so long, I practicaly forgot how to use it....
----------------------
Also I am attaching the text, 4men.txt
  I am also posting the code , I edited, it almost works ,I remarked where I don't know how to adjust, 1. to sycronize the images, so they go one by one with the key presses, and I get an error, when it gets to the longer line of text,..
 I know you mentioned, about the strings, earlier, but do not uderststand well enough,..Hope fully when I see how you fix it,..it will make better sense,..also of course, in this code the _putimage is still based on a 5 frame sprite sheet, the new one is 4, but I did not try to edit any of that part of the code,...---
 Hopefully it is pretty clear, I think it will be if you run it with the images,..

Note in the text one line is longer so it is actaully 2lines,..I do need to see how that is handled,...I think it will be almost self explaining by the way I wrote the text, 1st the This is a story about 4 men, would show, ( with the press anykey to continue), on the keypress, the 1st image, with the first line,..this is bob nice to meet you, the 2nd is the one with 2 lines, and the next image,is Jim, and so on,..hope I make sense...
from Garry
Here is the code:
Code:
   DEFLNG A-Z

SCREEN _NEWIMAGE(640, 480, 32)
WorkPage& = _LOADIMAGE("4men.png")
CLS

GOSUB MakPhrases 'get the amount of lines so we can make a dim to gather them
IF maxlines& <> 0 THEN
    DIM Phrases$(maxlines&)
    GOSUB FillDim 'read individual phrases into the string dim
ELSE
    PRINT "File not found": _DELAY 3: END
END IF
_DELAY .5

_DEST 0
Textprn$ = "THIS IS A STORY ABOUT 4 MEN ": RRow% = 2: CColumn% = 6: z% = 0: Pause! = .5: Whatone% = 0
GOSUB Showtext
GOSUB Pickphrase
RRow% = 15: CColumn% = 20: z% = 0: Pause! = .050
'//Need to figure out how to sycronize the images, with text
DO
    FOR x = 0 TO 261 STEP 67
        _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
        _DELAY .08
    NEXT
    GOSUB Showtext

    SLEEP

    LOCATE RRow%, CColumn%
    PRINT STRING$(Length%, 32)

    LOCATE 25, 4
    PRINT " press + hold escape to exit or any key to contimue"
    GOSUB Pickphrase
LOOP UNTIL _KEYDOWN(27)
SYSTEM
END
'--------------------------------------------------------------------------

Showtext:
z% = 0
Length% = LEN(Textprn$)
FOR a = 1 TO Length%
    LOCATE RRow%, CColumn% + z% '///When it gits to the longer line, that is when it errors, saying line 46
    PRINT MID$(Textprn$, a, 1)
    z% = z% + 1
    _DELAY Pause!
NEXT a
RETURN

MakPhrases:
maxlines& = 0
ThisFile% = FREEFILE 'get next free file handle must be integer
OPEN "4men.txt" FOR INPUT AS #ThisFile%
DO
    INPUT #ThisFile%, temp$
    maxlines& = maxlines& + 1
LOOP WHILE NOT EOF(ThisFile%)
temp$ = "" 'dump contents of string
CLOSE #ThisFile%
RETURN
'///Not exactly sure how to explain, I think when you see the error that occurs,you will know how to handle it.
FillDim:
maxlines& = 0
ThisFile% = FREEFILE 'get next free file handle must be integer
OPEN "4men.txt" FOR INPUT AS #ThisFile%
DO
    INPUT #ThisFile%, temp$
    Phrases$(maxlines&) = temp$
    maxlines& = maxlines& + 1
LOOP WHILE NOT EOF(ThisFile%)
temp$ = "" 'dump contents of string
CLOSE #ThisFile%
RETURN

Pickphrase:
Whatone% = Whatone% + 1
IF Whatone% > maxlines& - 1 THEN Whatone% = 1
Textprn$ = Phrases$(Whatone%)
RETURN
 
Thanks, and I happy I finally got back to this,...it is more fun then some of the other stuff Ive been doing! I am glad you reminded me about it...
« Last Edit: March 24, 2012, 05:08:05 pm by GarrisonRicketson » Report Spam   Logged

guest
Guest
« Reply #18 on: May 11, 2011, 08:26:27 am »


    Here's a piece of code to demonstrate how to split a string into chucks for display purposes. It demo's the idea but is not best cut and paste. It will need making into a dedicated callable sub that has passed to it the needed variables , etc.
To see its strength change the
Quote
CColumn% = 30
to other figures.
Code:
REM
SCREEN 12
Text$ = "This will be longer than 80 characters long deliberately so that we can compose and test a stand alone routine that can accomodate this more easierly than other methods we have chosen to use to illustrate it."

PRINT Text$
CColumn% = 30
GOSUB BreakString
SLEEP
SYSTEM

BreakString:
Chunks% = 0
Braklen% = LEN(Text$)
IF Braklen% > 80 - CColumn% THEN '---                              calculate if length of string will wrap over the screen edge
  'find out how many chunks there arebased off the amount of space between the printing column + edge of screen
  Legitlen% = 80 - CColumn% '----                                  this is max len to fit onscreen without wrap
  Chunks% = Braklen% \ Legitlen% '---                              divide to see if its non fractional
  IF Chunks% * Legitlen% < Braklen% THEN Chunks% = Chunks% + 1 '-- if fractional add 1 to the chunks
ELSE
  'line is already legit length
  Chunks% = 1
END IF
IF Chunks% = 1 THEN
  RETURN '--- handle normally
ELSE
  'goto plan B
  GOSUB PlanB
END IF
RETURN

PlanB:
SOUND 1000, 1
LOCATE 6, 1: PRINT Braklen%, Legitlen%, Chunks%
LOCATE 10, 20
DIM PartText$(Chunks%) '-- create a structure to split the string into chunks
Start% = 1
FOR t = 0 TO Chunks% - 1
  PartText$(t) = MID$(Text$, Start%, Legitlen%)
  LOCATE 10 + t, CColumn%
  PRINT PartText$(t)
  Start% = Start% + Legitlen%
NEXT t
RETURN

« Last Edit: March 24, 2012, 05:02:53 pm by GarrisonRicketson » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #19 on: May 11, 2011, 08:12:30 pm »

Thanks both, Dusty and Oldoslver,...
For both of these,...I will get back to them, as soon as I get some rest,..
They both help,...
from Garry
.I just now noticed this,
http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,157.msg835.html#msg835
 It shows, you posted it april 29,....? , but anyway, yes it sounds so simple,..
hmm,...
Again, I seem so close, but it is also so late,...and in the morning, I have so little time....it seems hopeless,..I just saved what I was doing,...so I can keep trying,..
 I see in these, where you are putting some of what you say in the tut, to work,...
 I just need to go back thru this thread, and study the tut some more,...
Any way thanks...
from Garry
« Last Edit: March 24, 2012, 05:03:34 pm by GarrisonRicketson » Report Spam   Logged

guest
Guest
« Reply #20 on: May 12, 2011, 04:41:37 pm »


    Garry here is another finished example that synchronises the pictures with the text. I think that is what you originally wanted. I cleared the screen to solve the problem of deleting the displayed text. Note a few changes
1] Line Input <-- allows commas to be read as part of the line and not a break in the line
2] Original dim now is reduced by 1 as array elements start at zero and not at one as expected
3]  New text file . Removed a blank line
4] This will fail if the line of text is too long.

    One of the reasons this seemed hard was that you cut and pasted code that didnt fit correctly together. I decided to simplify so that you have an example. Please note that the select case that decides the picture to display is HARD coded to a file of 5 lines. If you wanted to use another file of different length then you will have to add or subtract from the gosub.

Quote
This is a story about 4 men.
Bob-- Ths is BOB "hello nice to meet you."
Jim-- All he dose is sit and think all day, he never speaks and so we still do not know what it is he is thinking.
Joe-- He is half indian, and always likes to dance
Pete--Pete always likes to play soccer.
Here's the code
Code:
DEFLNG A-Z

SCREEN _NEWIMAGE(640, 480, 32) '<- what the observer sees
WorkPage& = _LOADIMAGE("4men.png") '<- all the graphics

CLS
_DEST 0 '<- point to the observer screen
GOSUB MakPhrases 'get the amount of lines so we can make a dim to gather them

LOCATE 2, 10
PRINT "THIS IS A STORY ABOUT 4 MEN "
Whatone% = 0 '<- set variable to zero


RRow% = 15: CColumn% = 20: z% = 0: Pause! = .050 'needed for the showtext routine

DO
  GOSUB Showpic 'sync pic with text
  RRow% = 15: CColumn% = 1
  GOSUB Showtext 'show text with the effect
  Dummy$ = INPUT$(1) 'wait for keypress
  CLS
  LOCATE 20, 10: PRINT " press + hold escape to exit or any key to contimue"
  GOSUB Pickphrase 'get next phrase
LOOP UNTIL _KEYDOWN(27)
SYSTEM
END
'--------------------------------------------------------------------------
Showpic:
SELECT CASE Whatone%
  CASE 0

  CASE 1
    x = 0
    _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
  CASE 2
    x = 67
    _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
  CASE 3
    x = 134
    _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
  CASE 4
    x = 201
    _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
END SELECT
RETURN

Showtext:
z% = 0
Length% = LEN(Textprn$)
FOR a = 1 TO Length%
  LOCATE RRow%, CColumn% + z% '
  PRINT MID$(Textprn$, a, 1)
  z% = z% + 1
  IF CColumn% + z% >= 79 THEN
    RRow% = RRow% + 1
    CColumn% = CColumn% - 60
  END IF
  _DELAY Pause!
NEXT a
RETURN

MakPhrases:
maxlines& = 0
ThisFile% = FREEFILE 'get next free file handle must be integer
OPEN "4men.txt" FOR INPUT AS #ThisFile%
DO
  INPUT #ThisFile%, temp$
  maxlines& = maxlines& + 1
LOOP WHILE NOT EOF(ThisFile%)
temp$ = "" 'dump contents of string
CLOSE #ThisFile%
'check maxlines to make sure file is not empty
IF maxlines& <> 0 THEN
  DIM Phrases$(maxlines& - 1) 'note arrys start at element zero not ONE as expected!!!
  GOSUB FillDim 'read individual phrases into the string dim
ELSE
  PRINT "File not found": _DELAY 3: END
END IF
_DELAY .5

RETURN

FillDim:
maxlines& = 0
ThisFile% = FREEFILE 'get next free file handle must be integer
OPEN "4men.txt" FOR INPUT AS #ThisFile%
DO
  LINE INPUT #ThisFile%, temp$
  Phrases$(maxlines&) = temp$
  maxlines& = maxlines& + 1
LOOP WHILE NOT EOF(ThisFile%)
temp$ = "" 'dump contents of string
CLOSE #ThisFile%
RETURN

Pickphrase:
Whatone% = Whatone% + 1
IF Whatone% > maxlines& - 1 THEN Whatone% = 0
Textprn$ = Phrases$(Whatone%)
RETURN

« Last Edit: March 24, 2012, 05:05:59 pm by GarrisonRicketson » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #21 on: May 12, 2011, 11:30:54 pm »

YES!, this is exactly what I was looking for,... Cheesy   I think this is resolved,..now,
It  is basicly pretty simple,....But can be "built up", Ie: Addng images to the sprite sheet, and new lines to the textI understand that each time a image is added:
Code:
          CASE 4
        x = 201
        _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
CASE 5    '///For example
x= 268
_PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67)
 
And if I understand, correctly, just by editing the textfile,adding the line that is for the new image. ---Edited:Had a question, but it got answered, when I tried,..works fine,...This is great!,..I added 1 more image, and also a line to the text,...and it worked fine,...
 Thanks alot Oldoslover,...
 It may sound silly, but I am going to enjoy this one,...

Quote
This will fail if the line of text is too long.
Thats ok, (Jim-- All he dose is sit and think all day, he never speaks and so we still do not know what it is he is thinking.)
So this is the maximum, length ? That is sort of why I threw in the one longest line, there is no need for any lines to be longer.  Those will always be short.
  All said and done, this is exactly what I was after,and should work fine,. I may do one, but  with,the wife,our son (alfosnso), the grandchild, and his Mom and Dad. So each line of text will be short, nothing more then a short "this is my wife." "This is Alfonso,our son",...and so on....
------------------------------------------------
Thanks, and this is a neat little "photo album",..or "sketch book" with captions,.. Now the BIG question,...
 How hard would it be to make a "user friendly", version, That, just Asks for  input, "Enter the filename of the image you want to add,Ie:filename.JPG,.BMP.PNG"
"Enter the text you want to go with the Image,limited XXnumber of charcacters"
 a menu with 2 options, VIEW my Album
                                 Edit My Album
Just a thought, later on down the road, ----believe me , when I first started
asking about this, I really wasn't sure what I was thinking,..nor why..!
From Garry
 

« Last Edit: May 13, 2011, 12:57:51 am by GarrisonRicketson » 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
Privacy Policy