I\'ve included my code with my first program, its not a game at present - its really boring infact. But potentially will be part of a game idea in the future, and wanted to start with the simplest part of an idea for a game(think elite on a planet). Its basically a stock marketstore type program. Though I want someone to comment on how this could be betterly programmed.
Of course I would like to write this arrays to a textfile etc - but is there any other way of writing this program with better technique as I felt this could of been done easier.
Dim 100,credits
Dim goods$(5,1)
Dim goods(5,3)
credits = 1000
goods$(1,1) = \"Sand\"
goods(1,1) = 5
goods(1,2) = 2
goods(1,3) = 50
goods$(2,1) = \"Scorpion Hide\"
goods(2,1) = 10
goods(2,2) = 6
goods(2,3) = 50
goods$(3,1) = \"Glass\"
goods(3,1) = 20
goods(3,2) = 10
goods(3,3) = 50
goods$(4,1) = \"Minerals\"
goods(4,1) = 25
goods(4,2) = 15
goods(4,3) = 50
goods$(5,1) = \"Diamonds\"
goods(5,1) = 50
goods(5,2) = 35
goods(5,3) = 50
rem specify maximum inventory
Dim inventory$(30)
Dim inventory(30)
rem base text positions
ytextpos = 50
xtextpos = 50
do
cls
ytextpos = 50
xtextpos = 50
rem position titles
text xtestpos+200, ytextpos-20,\"BUY\"
text xtestpos+250, ytextpos-20,\"SELL\"
text xtestpos+300, ytextpos-20,\"STOCK\"
rem display goods list
for goodslist=1 to 5
text xtextpos-20, ytextpos, str$(goodslist) + \".\";
text xtextpos,ytextpos, goods$(goodslist,1);
text xtestpos+200, ytextpos,str$(goods(goodslist,1));
text xtestpos+250, ytextpos,str$(goods(goodslist,2));
text xtestpos+300, ytextpos,str$(goods(goodslist,3));
print
ytextpos = ytextpos + 15
bottomlist= ytextpos
next goodslist
text xtextpos,bottomlist+30, \"Your Credits - \" + str$(credits);
rem display inventory
text xtestpos,ytextpos+125, \"** Inventory List **\"
for inventorylist=1 to 30
if inventory(inventorylist) = 0 or inventory$(inventorylist) = \"0\"
else
text xtextpos, ytextpos+140, inventory$(inventorylist)
text xtextpos+150, ytextpos+140, str$(inventory(inventorylist))
endif
ytextpos = ytextpos + 8
next inventorylist
set cursor 50, 200
input \"Would you like to (B)uy or (S)ell ? \";choice$
if choice$ = \"b\"
input \"What item would you like to purchase ?\";buyitem$
Rem print out what user input
For goodslist=1 to 5
If val(buyitem$) = goodslist
selectedgood = goodslist
Endif
next goodlist
$buy = \"How many units of \" + goods$(selectedgood,1) + \" would you like you buy?\"
input $buy; $units
rem stop stock being a negative
if val($units) <= goods(selectedgood,3)
rem take away units from store
goods(selectedgood,3) = goods(selectedgood,3) - val($units)
rem take away credits from customer
credits = credits - goods(selectedgood,1)
rem added the text of the good
inventory$(selectedgood, 1) = goods$(selectedgood,1)
rem add the units purchased
inventory(selectedgood) = inventory(selectedgood) + val($units)
else
print
print \"Sorry you cannot purchase that much\"
wait (3000)
endif
else
rem sell function
endif
print \"haven\'t created function to sell yet\"
wait (3000)
loop
rem End the program