Anonymous user
RCRPG/uBasic-4tH: Difference between revisions
m
→The code
(Added uBasic/4tH version) |
imported>Thebeez m (→The code) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 25:
6 bits = directions (udsnew)
</pre>
The "player" structure was crammed in an integer as well - but that wasn't really required. It's just neat since it makes the code
This implementation really uses [[uBasic/4tH]] strengths. The <code>NAME()</code> function converts an ordinary string to a label, while <code>LINE()</code> returns true when the label has been defined. The <code>PROC</code> keyword can call a procedure directly by using an expression.
Line 33:
The entire program is about 450 lines. It could have been factored a bit better, agreed, but it feels more readable now.
==
<syntaxhighlight lang="basic">Dim @r(216) ' these are our rooms▼
▲Dim @r(216) ' these are our rooms
i = Rnd(36) ' now place the person in a room, floor 0
Line 93 ⟶ 92:
Print : Print
Print "Things of interest here:"
b@ = And(@r(a@)/65536, 255)
c@ = And(@r(a@)/256, 255)
If b@ Then Print "\t";b@;" piece(s) of gold"
Line 103 ⟶ 102:
If @r(a@)/128 = 0 Then Print "\tNothing"
If And(@r(a@), 64) Then ' see if we are in the prize room
Print
Print "You found the Prize Room!"
Line 118 ⟶ 117:
While Len(c) ' any string left?
While Peek(c, 0) = Ord(" ") ' is it a space?
c = Chop(c, 1) ' split off space
Next
a@ :=
Do ' start after leading spaces
Line 163 ⟶ 162:
Proc _TakeAll ' be greedy
Else Print "Hey, just what you see, pal!\n"
EndIf EndIf EndIf EndIf ' no
Return
Line 207 ⟶ 206:
EndIf
Push ((And(i/256, 255) + And(@r(a@)/256, 255)) * 256)
i = ((i/16777216) * 16777216) + Pop() + Pop() + a@
@r(a@) = And(@r(a@), 63)
Else
Line 222 ⟶ 223:
If Comp(a@, "sledge") = 0 Then
Proc _EquipSledge
Else If Comp(a@, "ladder") = 0 Then
Proc _EquipLadder
Else Print "You can't equip that.\n"
EndIf EndIf
Return
Line 265 ⟶ 266:
Proc _DropAll ' be greedy
Else Print "You can't drop what you don't have.\n"
EndIf EndIf EndIf EndIf ' no
Return
Line 314 ⟶ 315:
EndIf
Push ((And(@r(a@)/256, 255) + And(i/256, 255)) * 256)
@r(a@) = Pop() + Pop() + And(@r(a@), 255)
i = And(i, 255)
Else
Line 356 ⟶ 359:
_down
If And(i, 255) < 36 Then Print "You can't go down.\n" : Return
If And(@r(And(i, 255) - 36), 128) = 0 Then Print "You'll need a ladder.\n" : Return
If And(@r(And(i, 255)), 16) = 0 Then i = i - 36 : Return
Line 379 ⟶ 383:
Print
Print "take (all|item name)"
Print "\
Print
Print "inventory"
Line 505 ⟶ 509:
Print "Equip the sledge first. If you got one..\n"
EndIf
Return</syntaxhighlight>
|