Using Darkbasic(normal)
I have written a function which contains 2d text on-screen. This function is called(entershop) when a certain object is hit. However the 2d text onscreen appears for a moment and disappears.
The 2d text function contains a loop which it needs to perform(for a shop scenario). I've tried using "DRAW TO FRONT", CLS, INK(,,) etc - and no result. Though you are able to still input on the keyboard but there is a problem with switching from 2d to 3d somewhere??
Here is the source code for my program at present
Sync On
Sync Rate 40
Rem make matrix
Make matrix 1,10000,10000,20,20
Rem texture matrix
Load image "grass.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem make the building
make object box 50,100,100,100
position object 50,600,4,600
color object 50,rgb(100,200,100)
rem make the marker to park
make object box 51, 50,100,50
position object 51, object position x(50), object position y(50), object position z(50)-100
rem osition object 51,600,4,500
color object 51,rgb(100,100,100)
ghost object on 51
Rem Make player pawn
Load image "jeep1.bmp",2
LOAD OBJECT "jeep1.x",10
set object collision on 10
rem Make object sphere 10,25
Texture object 10,2
position object 10,100,0,100
make object collision box 10,-5,-5,-5,5,5,5,0
disable object zdepth 10
Rem Set speed of Jeep
speed#=0.0
rem Randomize the matrix
rem randomize matrix 1,125
Rem Main loop
Do
set cursor 0,0
rem detect collision - crap collision effect at present
if object collision(10,50)>0
Position object 10,X#,Y#,Z#-20
rem dec X#,get object collision x()
rem dec Y#,get object collision y()
rem dec Z#,get object collision z()
endif
rem if car placed inside circle then enter building
if object collision(10,51)>0
draw to front
entershop()
rem position object 10, X#,Y#,Z#-20
endif
Rem Store Object angle
AngleY# = object angle Y(10)
Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,AngleY#,20)
ZTest# = Newzvalue(Z#,AngleY#,20)
speed# = speed# + 2.0
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
Move object 10,10
Endif
Endif
If Leftkey()=1 then Yrotate object 10,Wrapvalue(AngleY#-5)
If Rightkey()=1 then Yrotate object 10,Wrapvalue(AngleY#+5)
X# = Object position x(10)
Z# = Object position z(10)
Y# = Get Ground Height(1,X#,Z#)
Position object 10,X#,Y#+12.5,Z#
CameraZ# = Newzvalue(Z#,AngleY#-180,100)
CameraX# = Newxvalue(X#,AngleY#-180,100)
CameraY# = Get Ground Height(1,CameraX#,CameraZ#)
Position camera CameraX#,CameraY#+50,CameraZ#
Point camera X#,Y#+25,Z#
Rem Refresh Screen
Sync
Loop
function entershop()
draw to front
ink rgb(244,214,210),0
cls 0
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
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
endfunction