Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Inserting input

Author
Message
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 25th May 2005 04:04
Hi all,
i would like to know how to do a easy screen at the beginning of my game, where i have a textbox to put the Nick of a player. I didn't find any about that, I also would like to know an easy way to store the Nick/Score on a file !
Thank you
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th May 2005 04:08
Well... to input something we usually use "input"...
for ex:

input "give your nickname: ",nick$
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 25th May 2005 04:20
mm i can be allright, but anyone knows any other kind of input data like using textboxes and labels?
A more Windows-king of screen i mean
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th May 2005 04:49
Well, you can draw a lot of 2D boxes...

But I heard about a DLL called BlueGUI. But since i don't have the enhanced version of DBC, I usually don't spend much attention on DLL's
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 25th May 2005 05:45
ok, but why does the backdoor screen seems to "flash" when inputting something? how can i change the background color?

And what about files? Could u tell me the basic info's, to create/append/read/create a file ? ^^
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 25th May 2005 05:59 Edited at: 25th May 2005 06:00
To change the backdrop color you must first use the Backdrop On command and then use the Color Backdrop command. It would be easier to help you with the flashing problem if you posted some code. And for the storing data part you can go here:

http://www.freewebs.com/underworld1020/tutorials.htm

Let me know if you have anymore questions .

NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 25th May 2005 06:18
thank you very much for the link!

for the flashing problem... now i just see a blue screen instead of the previous "flash", but i can't read what i write on the screen.. it seems that it is written in the same color of the background, i also tried to change backdrop color but i can't read it anyway.

the piece of code of the beginning is like this:

Sync on
Sync rate 60
hide mouse

Backdrop on
Set camera range 1,5000
Autocam off


input "enter your name>";name$

randomize rnd(20)
fog on
fog color RGB(0,0,150)
fog distance 1500
Set ambient light 80
....
....
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 25th May 2005 22:21
The INPUT function shows the text UNTIL the enter key is pressed, you must use a TEXT x,y,name$ for example, for showing it after.

Hope to have helped!

NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 25th May 2005 22:50
do you mean something like that?

input name$
text 20,20,"enter your name>"

but i firstly see the blue screen, and next, when enterkey is pressed, i see for a moment the string printed on the screen

mmmmmm... i also dont understand why when typing, i just see for a moment the printed letter on the screen, and then it becomes of the same color of the background ..
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 25th May 2005 23:55
well, i have a question now, about files.

SET DIR "C:\"

IF FILE EXIST("Game.dat")=1 THEN DELETE FILE "Game.dat"

OPEN TO WRITE 1,"Game.dat"

WRITE STRING 1,STR$(Health)

CLOSE FILE 1

is there an "append" instruction?
i mean, an instruction that places the buffer at the end of the file, to start writing ?
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 26th May 2005 00:47
I don't think there is, it kinda just puts the data on the next availible line. Thats why you have to read in the data in the same order as you wrote it. It would be nice if there was a command like that, however I might be able to make a function that will set the current position, I'll see if I can make something for ya.

NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 26th May 2005 01:26
well you could, save all the data before on array. and then write them all in to the file
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 26th May 2005 05:47
That might work, but I've got something better, I created my own file command functions and so far I have Create_File and Write_String. I'm going to start making Read_String, I'll post the functions in a little bit. With these you'll be able to specify which line number you want to work with and plus the files them self are more organized.

Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 26th May 2005 22:36
so, i should read all the data stored on the file, and count the number of lines, then write_string on that line number ?

it sounds odd that darkbasic can only create a new file, and can't add string on a old one....
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 27th May 2005 04:16
Well, if you open up the file you created like in notepad, you can see all the data in the file, and each line is marked with it's line number so you won't have to count anything, thats the good part. Also you can change a line in the file as many times as you want with the Write_String() function. With DarkBasic's file commands you can't pick a line and put data there, you have to go in order, and once you close the file you can no longer edited the file. Thats why I created the functons, so you can do those things.

NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 27th May 2005 05:27
well...

i want to save the scores on a file each time i finish my game, storing "Nick, Score", so i want to add a new bottom line each time i run my game, so i don't know the position!

is there a "namefile.EOF" to loop?

while(file.EOF)
loop

but, the "OPEN TO WRITE ..." instruction, creates a new file each time... so i can't make the loop i think..
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 27th May 2005 05:53
So, you want to make like a highscore list?

NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 27th May 2005 06:01
yea i would, on a file.
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 27th May 2005 06:02 Edited at: 27th May 2005 06:19
Ok, hold on...

EDIT: 1 more sec...

Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 27th May 2005 07:01 Edited at: 27th May 2005 07:04
Ok, I used my functions to create a highscore list. Here's the code:



Just run it and it will ask you for your score, when you actually use it for something you won't want it to ask you, but be whatever score the player got. Then close out of the program and then run this code to check the highscore list:



I made it so it does a highscore list of only three scores, but I'll make when where you can have any size list you want, I'll do that tonight. Let me know how it works .

NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 27th May 2005 23:38
well i don't really understand all your code...

but i would understan it becouse, i have to explain it to my teachers (it's a project for an exam)...

and i can't know from the beginning the size of all the list... maybe it can be made of 1000 rows!
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 1st Jun 2005 01:09
Here's an easier way to make a high score list.



The first thing it does is it creates an string array called HSL, which just means High Score List, I just made it up. Then it goes into the SetDefault_HSL subroutine.

When it goes there it sets the HSL array to 300, 200, and 100. 300 is first place, 200 is 2nd place, and 100 is 3rd place. Then it goes back up to the top where it left.

This line tells it to ask the user for there score with the Input command and stores it into the Score varible, and then it goes into the Check_HSL subroutine.

The first thing it says is if the Score varible is greater then the 3rd place score and also less then the 2nd place socre then then the score must go in the 3rd place score. It tells a string varible called Rank to equal "3rd", this stirng varible will be used later to tell the user what place that got. Then it tells the 3rd place score to equal the Score varible.

The next thing it does is that if the Score varible is greater then the 2nd place score and less then the first place score then it must be equal to 2nd place. It tells it set the string varible Rank to 2nd. Then it tells the 3rd place score to equal the second place score because before the new score can be put into 2nd place the old scores must first move down the list the old 3rd place score will be thrown off the list and be replaced by the old 2nd place score. The 2nd place score is then set to the Score varible.

Then it says if the Score varible is greater then the 1st place score then set the string varible to 1st and then it tells it to move all the old score down the list and then put the new score in 1st place. Then the subroutine ends and it goes back up to the top where it left off.

This line tells the user what placed they ranked by using the Print command and it also uses the string varible Rank. Then it goes into the Save_HSL subroutine.

Then it goes there and it says that if the file HSL.dat already exists then delete that file, because the Open To Write command creates the file, so it can't already exist or things will get messed up. Next it tells it to create the file named "HSL.dat" and also to remember it as file number 1, so everytime you put a 1 in for a file number it knows that your talking about the HSL.dat file. Then it goes into a For Loop, which uses the Write String command to store all the scores into the HSL.dat file. Then it tells it to close file 1. Then it goes back up to the top where it left off.

Here it uses the UnDim command to delete the string array HSL and then create it oever again. This would be the same thing as closing the program and then reloding it again. Then it goes into the Load_HSL subroutine.

Here it does the same thing as the Save_HSL subroutine, except this time it takes the highscores that were saved to the file and load them into the program.

Then it just uses the Print command to output the highscore list. Thats all there is to it, let me know if you get confused.

Login to post a reply

Server time is: 2025-05-23 00:31:17
Your offset time is: 2025-05-23 00:31:17