TerraCalc - Terraria for TI-84 Plus CE

UPDATE

I have changed the format so that the screen is divided into 640 blocks (all stored in matrices). The terrain is still randomly generated, but this system will allow a survival mode to be created. Right now you can move but not into any blocks.

Things to do:

Add a way to break and place blocks

Figure out sprites (for moving character)






[OLD POST]


This is a program I've been working on for a couple days. It randomly generates a world, which is one of three biomes: Forest, Tundra, or Alien. Each world has its own unique features (Tundra has snow and pine trees, Alien has a flying saucer that shoots out light beams). If you dig to the bottom of the world, it generates a cave level. Everything can be saved (you can exit the program and turn off calculator). Right now, you can build without limitations, but I hope to make a survival mode soon. If anyone knows how to implement a survival mode, please feel free to help (no assembly, only basic). I will post the code in a couple days once it is less of a mess.




Why only Basic?
Pieman7373 wrote:
Why only Basic?


I want to keep this as simple as possible; and I believe it can be done without assembly. I only know some assembly, but if I have to use it for the game I will.
How smoothly/quickly does the game run without basic? It seems to be a pretty advanced game to be running without asm or C.
I like how this looks like. I am curious about how fast those graphics are drawn.
CHill wrote:
How smoothly/quickly does the game run without basic? It seems to be a pretty advanced game to be running without asm or C.
You would be surprised at how fast some BASIC programs can get, but unfortunately on a color 84+ the pure BASIC possibilities are lower than on monochrome models (mainly due to lack of dual-layer ASCII support)
This looks great dank. Good job on those graphics. Did you use the randInt command to create the uneven grounds? Also, is this a type of mine craft game, or something else?
DJ_O wrote:
You would be surprised at how fast some BASIC programs can get, but unfortunately on a color 84+ the pure BASIC possibilities are lower than on monochrome models (mainly due to lack of dual-layer ASCII support)

Can you elaborate on this please? Are you saying BASIC programs on the TI84+C are slower than the TI84+?
On the C yes, but on the CE no for the most part. The screen is larger, though, so it takes longer to fill and some special 84+ Basic tricks won't work on the C and CE
For those of you questioning the speed, the generation of a world takes between 20 and 40 seconds (depending on world type). Saved worlds load instantly. Cave levels (which generate when you reach the bottom of the map) take around 15 seconds. To generate a world, I used rand, so the top of the terrain is between 0 and 1 (8 pixels)(on zoom standard). In the customization menu, you can change the smoothness of a world (smooth worlds take longer to generate). These times were calculated using an average smoothness world with average numbers of trees.

Here's the code (it's very messy, but easy enough to follow):


Code:

12→D
0→U
AxesOff
ClrDraw
ClrHome
ZStandard
BackgroundOff
0→I
Menu("USE SAVED WORLD?","LOAD SAVE",LZ,"CREATE NEW",UQ)
Lbl LZ
If R=1
Goto LM
Goto FE
Lbl UQ
Menu("TREE SPAWNS","COMMON",LK,"SPARSE",LJ,"RARE",LI
Lbl LK
1→W
Goto LH
Lbl LJ
2→W
Goto LH
Lbl LI
3→W
Lbl LH
Menu("TERRAIN","SMOOTH",NO,"AVERAGE",NP,"ROUGH",NQ
Lbl NO
.4→O
Goto NR
Lbl NP
.6→O
Goto NR
Lbl NQ
.8→O
Lbl NR
0→F
Menu("BIOME","TEMPERATE",PQ,"TAIGA",PR,"ALIEN",PU,"RANDOM",PS
Lbl PQ
0→J
Goto PT
Lbl PR
1→J
Goto PT
Lbl PU
2→J
Goto PT
Lbl PS
randInt(0,2)→J
Lbl PT
If J=1
Goto SN
If J=2
Goto AN
11→L
0→K
W+1→W
While 1=1
L+2→L
L→X
randInt(1,W)→Z
If Z=2
Then
rand→Z
Z+X→X
rand→Z
Z→Y
randInt(1,2)→Z
If Z=2
1+Y→Y
Y+1.5→Y
Line(X,0,X,Y,1,16)
For(Z,0,.5,.1)
Circle(X,Y+.5,Z,14)
End
End
K+1→K
If K=10
Goto LG
End
Lbl LG
10.15→X
.5→G
.5→D
.5→S
While 1=1
X+.15→X
Lbl RM
rand→Z
If Z>G+O or Z<G-O
Goto RM
Z→G
Line(X,Z,X,2,1,14)
Lbl RN
rand→Z
If Z>D+O or Z<G-O
Goto RN
Z→D
Z-1→Z
Line(X,Z,X,5,1,16)
Lbl RO
rand→Z
If Z>S+O or Z<S-O
Goto RO
Z→S
Z-4→Z
Line(X,Z,X,10,1,GRAY
If X≥10.15
Goto WR
End
Lbl SN
11→L
W+1→W
While 1=1
If L=9
Goto ST
L+2→L
L→X
randInt(1,W)→Z
If Z=2
Then
rand→Z
Z+X→X
rand→Y
Y+1→Y
randInt(1,2)→Z
If Z=1
Y+1→Y
Line(X,0,X,Y,1,16)
Line(X-.5,Y+.2,X+.5,Y+.2,1,14)
Line(X-.4,Y+.6,X+.4,Y+.6,1,14)
Line(X-.3,Y+1,X+.3,Y+1,1,14)
Line(X-.2,Y+1.4,X+.2,Y+1.4,1,14)
Line(X-.1,Y+1.8,X+.1,Y+1.8,1,14)
Line(X,Y+2.2,X,Y+2.2,1,14)
Line(X-.5,Y+.4,X+.5,Y+.4,1,14)
Line(X-.4,Y+.8,X+.4,Y+.8,1,14)
Line(X-.3,Y+1.2,X+.3,Y+1.2,1,14)
Line(X-.2,Y+1.6,X+.2,Y+1.6,1,14)
Line(X-.1,Y+2,X+.1,Y+2,1,14)
End
End
Lbl ST
11→X
.5→G
.5→D
While 1=1
X+.15→X
Lbl KM
rand→Z
Z→Y
If Y>G+O or Y<G-O
Goto KM
Line(X,3,X,Y,1,LTGRAY
Z→G
Lbl KN
rand→Z
Z-3→Y
If Z>D+O or Z<D-O
Goto KN
Line(X,Y,X,11,1,GRAY
Z→D
If X≥11
Goto WR
End
Lbl AN
11→X
.5→G
ClrDraw
While 1=1
X+.15→X
Line(X,10,X,10,1,12)
If X≥10.01
Goto VY
End
Lbl VY
0→M
While 1=1
M+1→M
randInt(9,9)→X
randInt(1,9)→Y
Pt-On(X,Y,1,YELLOW
If M=15
Goto UT
End
Lbl UT
11→X
While 1=1
X+.15→X
Lbl QL
rand→Z
If Z>G+.4 or Z<G-.4
Goto QL
Z→G
Line(X,Z,X,Z-2,1,RED
Line(X,Z-2,X,Z-4,1,ORANGE
Line(X,Z-4,X,Z-6,1,RED
Line(X,Z-6,X,Z-8,1,ORANGE
Line(X,Z-8,X,Z-10,1,RED
Line(X,Z-10,X,Z-11,1,ORANGE
If X≥10.01
Goto KF
End
Lbl KF
randInt(7,7)→X
For(P,0,1.9,.1)
Circle(X,7,P,MEDGRAY
End
Circle(X,7,2,NAVY
For(P,0,.9,.1)
Circle(X,8,P,GREEN
End
Circle(X,8,1,NAVY
Pt-On(X,6,NAVY
Pt-On(X-1.15,6.3,NAVY
Pt-On(X+1.15,6.3,NAVY
Pt-On(X+1.5,7.3,NAVY
Pt-On(X-1.5,7.3,NAVY
X→V
Lbl RX
LTBLUE→D
0→X
1.5→Y
X→S
Y→T
4.5→E
Goto XR
Lbl FE
4.5→E
B→X
C→Y
LTBLUE→D
RecallPic 1
Lbl XR
While 1=1
E-.2→E
Line(V-1,E,V+1,E,1,MAGENTA
Line(V-1,E+.6,V+1,E+.6,1,12)
If E=.5
Then
Line(V-1,E,V+1,E,1,12
Line(V-1,E+.2,V+1,E+.2,1,12
Line(V-1,E+.4,V+1,E+.4,1,12
4.5→E
End
Pt-On(X,Y,1,D)
If S≠X or T≠Y
Pt-On(S,T,1,12)
getKey→Z
X→S
Y→T
If Z=24
Then
X-.15→X
If X≤10.01
10→X
End
If Z=26
Then
X+.15→X
If X≥10.01
10→X
End
If Z=25
Then
Y+.3→Y
If Y≥10.01
10→Y
End
If Z=34
Then
Y-.3→Y
If Y≤10.01
10→Y
End
If Z=21
Then
2→I
Goto VU
End
End
Lbl WR
0→X
1.5→Y
Y→T
X→S
12→D
Goto PY
Lbl LM
RecallPic 1
B→X
C→Y
1→U
Lbl PY
While 1=1
Pt-On(X,Y,1,D)
If S≠X or T≠Y
Pt-Off(S,T)
getKey→Z
X→S
Y→T
If Z=24
Then
X-.15→X
If X≤10
10→X
End
If Z=26
Then
X+.15→X
If X≥10
10→X
End
If Z=25
Then
Y+.3→Y
If Y≥10.01
10→Y
End
If Z=34
Then
Y-.3→Y
If Y≤10
Then
Pt-Off(X,Y+.3)
Goto CV
End
End
If Z=21
Then
0→I
Goto VU
End
End
Lbl VU
Menu("GAME PAUSED","RETURN TO GAME",RY,"INVENTORY",IY,"SAVE AND QUIT",QS,"QUIT",QT,"SETTINGS",BE
Lbl RY
If I=0
Goto PY
If I=2
Goto XR
Goto RU
Lbl IY
Lbl QS
Pt-Off(X,Y)
If I=0
1→R
If I=2
2→R
If I=0 or I=2
StorePic 1
If I=1
StorePic 2
X→B
Y→C
Lbl QT
ClrDraw
ClrHome
Disp " "
AxesOn
ClrHome
Stop
Lbl BE
ClrHome
Menu("SETTINGS","BACK",VU,"CHARACTER",CT
Lbl CT
Menu("COLOR","BLACK",BK,"BLUE",BU,"MAGENTA",MG,"RED",RD
Lbl BU
NAVY→D
Goto BE
Lbl BK
12→D
Goto BE
Lbl MG
13→D
Goto BE
Lbl RD
11→D
Goto BE
Lbl CV
X→θ
StorePic 1
ClrDraw
If U=1
Then
RecallPic 2
Goto RK
End
11→X
ClrDraw
While 1=1
X+.15→X
rand→Z
Z-4→Z
rand→V
V-8→V
Line(X,10,X,Z,1,GRAY
Line(X,10,X,V,1,GRAY
If X≥11
Goto RK
End
Lbl RK
10→Y
θ→X
X→S
Y→T
Lbl RU
While 1=1
Pt-On(X,Y,1,D)
If S≠X or T≠Y
Pt-Off(S,T)
getKey→Z
X→S
Y→T
If Z=24
Then
X-.15→X
If X≤10.15
10→X
End
If Z=26
Then
X+.15→X
If X≥10.15
10→X
End
If Z=25
Then
Y+.2→Y
If Y≥10.2
Then
Pt-Off(X,Y-.2)
Pt-On(X,10,1,GRAY
StorePic 2
1→U
ClrDraw
RecallPic 1
10→Y
Goto PY
End
End
If Z=34
Then
Y-.2→Y
If Y≤10.01
10→Y
End
If Z=21
Then
1→I
Goto VU
End
End
Holy moly labels labels labels. But hey if it works, that's great!! I'm really surprised at how you can generate a landscape in pure basic like that. Fantastic job! I would recommend using TI Connect CE or CEmu for your screenshots though. Very Happy
Yeah, I've had trouble with TI Connect. For whatever reason, I can only connect to the non-ce version, so I can't do screenshots Razz
I too am quite impressed to see that you can generate these kinds of maps in pure basic.
quickly looking at your code, I can see you could really benefit from having loops in there and maybe cut down on labels
Code:
If U=1
Then
RecallPic 2
Goto RK
End

This kind of thing is a no no, you may already know this but this causes a memory leak. The fact that it can sometimes be quite hard to use them without causing memory leaks is one of the reasons why people on here will often discourage the use of labels. Also, overusing them quickly creates spaghetti code which is not technically a problem, but makes it much harder for other people to follow along, and easier for you to get lost.

Code:
While 1=1


dankcalculatorbro wrote:
Yeah, I've had trouble with TI Connect. For whatever reason, I can only connect to the non-ce version, so I can't do screenshots Razz

To connect to a CE, you need ti-connect CE. However, ti-connect CE can connect to older models so I would recommend using that. Additionally, ti-connect CE is faster.
Also,

Code:
randInt(9,9)→X
is just
Code:
9→X
dankcalculatorbro wrote:
Yeah, I've had trouble with TI Connect. For whatever reason, I can only connect to the non-ce version, so I can't do screenshots Razz

I have encountered this problem before, I think.
TI-Connect CE wont work if TI-Connect is installed (it won't detect youf calculator). Try uninstalling TI-Connect.

P.S. That looks very impressive! Good Idea Wish I had a CE.
Thank you Kydapoot! Uninstalling the old TI Connect fixed the problem. I am going to update the pictures with screenshots soon.
Glad I could help. Cool
To test and post animated screenshots you can also install CEmu.

This looks very cool, but why is the terrain less detailed in the newer screenshot? Is it speed problems?
Yes, partly for speed. Generating the world takes well over a minute. Also, since everything is saved in matrices, there is a size limit. The screens quadrants are each stored in their own matrix, because one matrix wasn't large enough.

I have added a way to break blocks: You hit second and then an arrow key to break a block adjacent to your character. Now I just have to implement a way to save the blocks you break in memory, then there will have to be a way to select what block you place.

NOTE: Since each block is about 10 x 10 pixels, I could texture each individual block, making the graphics better.
Ok, so I'm just about done. I will upload it to archives in the next week.

Features:

-randomly generated world (18 by 32 "blocks")
-survival mode
-press 2nd to toggle break/build mode
-press 1, 2, or 3 to place the corresponding block
-saving
-coded all in basic

Memory:

Matrix C (1500)
Matrix D (1500)
Matrix E (1500)
Matrix F (1500)
prgmTERRA (2000)

Total: 8000 bytes

Things that will be added in updates:

-breaking blocks all around (you can only break the one below you now)
-more blocks with textures (tree trunks, ect.)
-more biomes
-a second screen for each map (that loads if you move off the screen)
-maybe enemies?
-faster character movement using sprites
-possibly redoing the matrices meaning up to 5 screens could be generated and saved at a time
This sounds great. As you progress in your game and Basic knowledge, try optimizing the program down.
I will. I am rewriting the code so that the game only uses 2 matrices per screen, along with fixing some memory leaks so that the game runs a lot faster.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement