vintage-basic.net
June 17, 2021, 04:59:13 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Screen Using Array  (Read 18746 times)
rdc
Newbie
*
Posts: 13


View Profile Email
« on: December 31, 2009, 09:31:17 AM »

I worked up a little program to test the idea of using a string array to mimic writing to the screen. Seems to work OK.

Code:
10 REM SIMULATED LOCATE USING AN ARRAY
11 REM USING RAND DEF TO RANDOMLY PLACE CHARACTERS ON THE SCREEN
12 RANDOMIZE
13 DEF FN RN(S, L, H) = INT((H - L + 1) * RND(S) + L)
14 REM SET UP STRING ARRAY TO MIMIC SCREEN ROW, COLUMN ARE 0 BASED 24 LINES SO LAST LINE CAN BE USED FOR INPUT
15 DIM SCREEN$(24, 80)
16 REM RESET ARRAY AND PRINT TO CLEAR SCREEN
17 GOSUB 640
18 GOSUB 550
19 INPUT A$
20 FOR I = 1 TO 20
25  ROW = FN RN(1, 0, 23)
30  COL = FN RN(1, 0, 79)
40  SCREEN$(ROW, COL) = "*"
45 NEXT
46 REM PRINT TO SCREEN
50 GOSUB 550
51 INPUT A$
55 REM CLEAR SCREEN ARRAY
60 GOSUB 640
65 REM PRINT BLANK SCREEN
70 GOSUB 550
71 INPUT A$
80 END
545 REM PRINTS ARRAY TO SCREEN
550 FOR II = 0 TO 23
570   FOR JJ = 0 TO 79
580     PRINT SCREEN$(II, JJ);
590   NEXT JJ
610 NEXT II
620 RETURN
630 REM RESETS SCREEN ARRAY
640 FOR II = 0 TO 23
650   FOR JJ = 0 TO 79
660     SCREEN$(II, JJ) = " "
670   NEXT JJ
680 NEXT II
690 RETURN
Logged
Lyle Kopnicky
Administrator
Newbie
*****
Posts: 7


View Profile Email
« Reply #1 on: January 09, 2010, 10:41:43 AM »

Random stars... cool.
Logged
rdc
Newbie
*
Posts: 13


View Profile Email
« Reply #2 on: January 09, 2010, 03:02:48 PM »

Heh. Thanks.

When I get a break I am going to try and do the old robots game using this to see how it works.
Logged
E.K.Virtanen
Newbie
*
Posts: 11


312576736 lurah@luukku.com
View Profile WWW Email
« Reply #3 on: January 11, 2010, 12:14:26 PM »

hmm...it works, but only in a second row. Others just rolls a blank screen  Huh

Using ubuntu and xterm.
Logged

rdc
Newbie
*
Posts: 13


View Profile Email
« Reply #4 on: January 11, 2010, 02:21:10 PM »

It should display a blank screen, then one with stars and another blank screen. The blank screens are the clear screen function. Are you only seeing two rows of stars?
Logged
E.K.Virtanen
Newbie
*
Posts: 11


312576736 lurah@luukku.com
View Profile WWW Email
« Reply #5 on: January 14, 2010, 02:50:12 PM »

Ok, i had some weird settings in my xterm profile. I set them as default and decreased terminal size to 23*79 and now your code works.
Logged

rdc
Newbie
*
Posts: 13


View Profile Email
« Reply #6 on: January 16, 2010, 08:21:23 AM »

I think Vintage only supports the standard 80x25 terminal.
Logged
Lyle Kopnicky
Administrator
Newbie
*****
Posts: 7


View Profile Email
« Reply #7 on: January 19, 2010, 12:26:22 PM »

Nope, you can use any size terminal you like. Vintage BASIC knows nothing about the terminal size.
Logged
rdc
Newbie
*
Posts: 13


View Profile Email
« Reply #8 on: January 20, 2010, 05:15:51 PM »

Cool. That is good to know.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!