RCRPG/uBasic-4tH: Difference between revisions

m
(Added uBasic/4tH version)
 
imported>Thebeez
 
(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 muchmore harder to understandinteresting.
 
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.
 
== =The code ===
<syntaxhighlight lang="basic">Dim @r(216) ' these are our rooms
<lang>
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:" ' list anything of interest
 
b@ = And(@r(a@)/65536, 255) ' calculate pieces of gold
c@ = And(@r(a@)/256, 255) ' calculate sledges
 
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@ := Dup ("") ' start with an empty token
 
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 sauchsuch thing
Return
 
Line 207 ⟶ 206:
EndIf
 
i = ((i/16777216) * 16777216) +Push ((And(i/65536, 255) + And(@r(a@)/65526, 255)) * 65536) + ((And(i/256, 255) + And(@r(a@)/256, 255)) * 256) + a@
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 ' equip the sledge
Else If Comp(a@, "ladder") = 0 Then
Proc _EquipLadder ' equip the ladder
Else Print "You can't equip that.\n"
EndIf EndIf ' no such thing
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 sauchsuch thing
Return
 
Line 314 ⟶ 315:
EndIf
 
@r(a@) =Push ((@r(a@)/65536 + And(i/65536, 255)) * 65536) + ((And(@r(a@)/256, 255) + And(i/256, 255)) * 256) + And(@r(a@), 255)
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 "\t TaketTake the item specified. Or take everything in the room."
Print
Print "inventory"
Line 505 ⟶ 509:
Print "Equip the sledge first. If you got one..\n"
EndIf
Return</syntaxhighlight>
</lang>
Anonymous user