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.

Newcomers DBPro Corner / Making a box to input text while updating rest of screen

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 20th Feb 2011 20:04
I am looking to create a character sheet bit which so far i have loaded a simple background, it will display some simple variables depending on what character you chose and it allocates you some points to spend for each stat. Now i have a check running to see if its the first time you have loaded the character sheet since starting the game, if its not (say you open it at any point after the game has started or you level up) then i want the sheet to just display whatever name you have chosen - not too difficult.

What im having trouble with though is inputting the character name if you havent done it before. If i just use 'Input "Enter Name"; name' or whatever it stops updating the screen and doesnt paste any images as i would expect it too as it is waiting for you to input first.
How can i have a simple box that when you click in it, it then sets up a cursor for you to type you name, when you click enter it remembers and displays it. Then if you click it again it allows you to type over (or insert) what you typed previous.

Im thinking it has something to do with arrays and overwriting strings in arrays but i dont know much about this. Can anyone point me in the right direction?

Thanks.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Feb 2011 09:31
Quote: "What im having trouble with though is inputting the character name if you havent done it before. If i just use 'Input "Enter Name"; name' or whatever it stops updating the screen and doesnt paste any images as i would expect it too as it is waiting for you to input first."


The only way for full control of input is using the ENTRY$() command. It allows you to control every aspect of input and allow you to do things while getting input (instead of freezing all action with the INPUT command).



Quote: "How can i have a simple box that when you click in it, it then sets up a cursor for you to type you name, when you click enter it remembers and displays it. Then if you click it again it allows you to type over (or insert) what you typed previous.

Im thinking it has something to do with arrays and overwriting strings in arrays but i dont know much about this. Can anyone point me in the right direction?
"


You can use an array if you want but if it's just a name as long as the string Com$ isn't cleared it'll remember itself in the code (unless it's put into a function and not set as GLOBAL). Try adding the following before entering the DO/LOOP:



That will start the input with your name and show it because it prints Com$ then the prompt.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 21st Feb 2011 23:48
Where would i be without you Grog
That does seem to fit the purpose i had in mind. I had a little play with it and i understand a fair bit of it but had a few questions.

1) I take it that the first 'Clear Entry Buffer' has to be quite close to the do loop that that peice of code is in as it clears whatever the user might have typed while say loading screens or the like were part of the program. The further away this is the more time you have to sneak a key in (even though programs run very fast surely its possible if you held the key down for example)

2) a$=entry$(1) - The (1) part is a switch to make 'entry' automatically delete characters when backspace is pressed i think, if thats true why do i need the keystate(14) - i.e backspace - check?

3) I cant figure out what timer is for and why it is also declared as tim when tim = timer(), why not just use timer(), also what does it do? i know what it does in relation to randomize but not what it is here.

4) i see what the set text opaque does as without it, it certainly gets very messy, but on a nice neat picture background this would draw a horrible black (or whatever colour) box whereever you typed. Is there another way around this. I was thinking maybe another step where you add instantly what you type into another variable that you add to then sort of refresh the screen more deleting what was previously written but rewriting the new variable or something (i cant for the life of me think where to start)

5) and finally, if i drew an actual box (lines only not solid) after where it says "Enter Name: " how could i get the cursor to pop up there only when they click in that box, otherwise it remains (i cant think of the word im trying to use) inactive, i.e typing wont do anything on that screen. I think i have an idea about this, perhaps a mousex + y check to see if a click is done then going into the input name, then when enter is pressed it just goes to a 'text 50, 50 name' until you click in it again.

Sorry for all the questions but i experimented a little with no avail, and had a look at the commands in the help file and they just arent helpful enough.
Also while im on that note why does the free version of DB pro have the command help which takes you straight to the command your cursor is on, yet my full on paid for version doesnt have it. I have a free version at work that i tinker with just to test things out then the paid version at home and they are both updated and the same version yet mine doesnt seem to have it, just thought that was odd.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 22nd Feb 2011 05:11
Quote: "Where would i be without you Grog"


Thanks.

Quote: "1) I take it that the first 'Clear Entry Buffer' has to be quite close to the do loop that that peice of code is in as it clears whatever the user might have typed while say loading screens or the like were part of the program. The further away this is the more time you have to sneak a key in (even though programs run very fast surely its possible if you held the key down for example)"


Yeah, that's exactly why that's there. The ENTRY$() command keeps every key pressed while Darkbasic Pro is running (with or without the command).

Quote: "2) a$=entry$(1) - The (1) part is a switch to make 'entry' automatically delete characters when backspace is pressed i think, if thats true why do i need the keystate(14) - i.e backspace - check?"


It only works if you don't use CLEAR ENTRY BUFFER while getting input and use the string from ENTRY$() to show input (like the example in the help files for ENTRY$()). I prefer more control over everything so I extract a character from ENTRY$() and add it to another string. Also without CLEAR ENTRY BUFFER if I tried to add the string from ENTRY$() to another string it would copy the input over and over again adding keys "a" would be "aa" then "aaaa" then "aaaaaaaa" doubling input very quickly.

Quote: "3) I cant figure out what timer is for and why it is also declared as tim when tim = timer(), why not just use timer(), also what does it do? i know what it does in relation to randomize but not what it is here."


Actually in this case it doesn't have anything to do with randomization but I'll talk about that first. The TIMER() is always counting up from the moment you turn your computer on that's why it's good to use it as a random seed because random number picking isn't exactly random. If you use the same exact seed it'll always pick exactly the same random numbers making it perfect for making encryption/decryption routines. We use RANDOMIZE TIMER() to make sure random number picking will be different each time the program runs because 99.9% of the time the TIMER() will be a different number when a user runs our programs. As a general rule if you're going to pick random numbers then add RANDOMIZE TIMER() once at the top of your code somewhere.

Now because the TIMER() is always going up we can't use it by itself to time anything so we use variables to store the current number from TIMER() (like Tim). We then compare the current number in TIMER() vs the stored TIMER() in the variable to determine how many milliseconds have gone by. In this case if the check for TIMER()>tim+100 was removed (or the TIMER() reset) just hitting the backspace key once would erase too many characters way too fast... usually the entire line of text.


Quote: "4) i see what the set text opaque does as without it, it certainly gets very messy, but on a nice neat picture background this would draw a horrible black (or whatever colour) box whereever you typed. Is there another way around this. I was thinking maybe another step where you add instantly what you type into another variable that you add to then sort of refresh the screen more deleting what was previously written but rewriting the new variable or something (i cant for the life of me think where to start)"


Yeah using SET TEXT OPAQUE is just a quick and dirty way to erase text on the screen for that example. There's an easier way than what you described. All you need is a screen sized image as a background (or just the input box size) and PASTE IMAGE or a simple BOX command to fill the area the text is going to be or even copied bitmaps. The text is redrawn every time so anything that clears the text will make backspace magically work without SET TEXT OPAQUE.

Same code using a bitmap:


Quote: "5) and finally, if i drew an actual box (lines only not solid) after where it says "Enter Name: " how could i get the cursor to pop up there only when they click in that box, otherwise it remains (i cant think of the word im trying to use) inactive, i.e typing wont do anything on that screen. I think i have an idea about this, perhaps a mousex + y check to see if a click is done then going into the input name, then when enter is pressed it just goes to a 'text 50, 50 name' until you click in it again."


You just make a routine to check the MOUSEX() and MOUSEY() to determine if the user is within in the box you want and MOUSECLICK() to see if they actually click a mouse button. We usually make an IF/THEN check like this: If MOUSEX()=>top left of boxes X coordinate and MOUSEY()=>top left of boxes y coordinate and MOUSEX()<=bottom right of boxes X coordinate and MOUSEY()<=bottom right of boxes Y coordinate.

Like this:


Where the text for "Button Hit!" is when you run the input routine is put or GOSUB to the input routine or call a function.

Quote: "Sorry for all the questions but i experimented a little with no avail, and had a look at the commands in the help file and they just arent helpful enough."


It's ok, that's why the Darkbasic Forums exist. I'm not sure why it would do that. I personally like to use Indigo and BlueIDE which both have a help window that's always on (if we choose) that automatically updates when you click on a command (see attached image). I use them because they both allow saving of code snips in a tab that's easy to access quickly.

BlueIDE: http://blueide.sourceforge.net/
Indigo: http://forum.thegamecreators.com/?m=forum_view&t=173446&b=8

Attachments

Login to view attachments
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 22nd Feb 2011 17:06
Excellent, i am going to try these tonight when i get back from work but from here i pretty much understand everything you have put to answer my questions. The only one i might get stuck on is my question (5) i had a quick read and ill have a play with some code later on. If i am still a little unsure ill let you know. Everything else looks ace though.

Once again thanks!
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 23rd Feb 2011 00:22 Edited at: 23rd Feb 2011 00:26
Ok, i had a damn good play around with this but unfortunately came up short of what i was expecting.
When i do a direct copy paste of your code it works a charm, especially with the second part added that makes everything under where the text is supposed to be still 'happen'
Now i made my own and incorporated it into the program i am making to help me learn as i go but cant get it working so i broke it down into another project in DB and fiddled about with it without the rest of the code in the way so i can just get this segment working (thats why its very very messy) but i cant even seem to get it to do what you did. It only has a few modifications which were what i was originally aiming for.

1) It wont take anything on that you type unless you clicked inside a certain box (which will be next to enter name, but in this case is a box located 100 down and across from the start just for ease), that is one change to what yours is.

2) Prints the letters as you type and updates the deleted keys (as yours does) - This is something mine just does not do.

3) Keeps the name then displayed until you click in the box again to which is will overwrite what you type (but not in a messy way, overwrite clearly not directly overlapping the existing text)

3) Flashing the cursor as well would be nice but i can only think of a very crude way of doing this that i didnt bother putting in here but it involved using the | key in a text statement to be placed just after where the string ends and doing something to make it blip on and off but at a normal speed, really cant figure this out.



It has to be something to do with that damn If statement that is to make the mouse box (because the condition is only true for the nanosecond the user clicks the left button, yet it goes back to the loop) but ill be buggered if i know any other way, i tried everything i know but unless i copy your code word for word (which is great but does not precisley fit my purpose) it does not work.
There is a hell of a lot more code than this but this is where i have narrowed down the problem as the only thing this is really a part of is an If statement that checks to see if this is the first time you have been on this screen, other wise it just wants to print the name so you cant edit it.
candy
13
Years of Service
User Offline
Joined: 16th Feb 2011
Location: mycosplayclub.com
Posted: 23rd Feb 2011 10:54
Thank you for your discuss~!bennefit information from here

I wanna hold you, till the fears in me subsides..
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Feb 2011 00:39
Well, first when I said:
Quote: "Where the text for "Button Hit!" is when you run the input routine is put or GOSUB to the input routine or call a function."


I shouldn't of told you "the input routine is put"... I should of insisted on GOSUB or function. An input routine like this always needs to be separate to allow you to reuse the code as many times as you need. I'm not sure if you know about GOSUB but I tend to only use functions. Functions act like custom commands that can take in variables/strings and send back to the main program a variable/string. If you haven't used functions yet just let me know and I'll teach you about their use. In the code snip later in this message you'll see your code in a function.

Quote: "1) It wont take anything on that you type unless you clicked inside a certain box (which will be next to enter name, but in this case is a box located 100 down and across from the start just for ease), that is one change to what yours is."


It doesn't hold on to the name very long because every time the routine runs you make b$="" where it should be b$=name to carry over the old name to the input routine.

Quote: "2) Prints the letters as you type and updates the deleted keys (as yours does) - This is something mine just does not do."


The quick way is adding SET TEXT OPAQUE before the DO/LOOP and when you show b$ add a blank space to overwrite the text (with b$+" "). The blank space will clear the last letter the next time the TEXT command is seen.

Quote: "3) Flashing the cursor as well would be nice but i can only think of a very crude way of doing this that i didnt bother putting in here but it involved using the | key in a text statement to be placed just after where the string ends and doing something to make it blip on and off but at a normal speed, really cant figure this out."


A prompt that blinks can be made using another string that alternates between | and a blank space.



What the above does is it looks to see if P$ is a | and if it is it changes P$ to a space but if it's not a | it'll change P$ to a |. So it's either | or a blank space (to simulate a blinking |). To show it you just add it after b$.

Here's your code with modifications:


Now earlier I mentioned functions. Functions are a better way to do what you want because it allows you to reuse code as many times as you want without having to copy code each time you want to get text from the user. This will allow you to easily add as many text boxes as you need... you just call it with different coordinates and with another string.

Your code with a function:


Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 24th Feb 2011 21:47
A little confusing but im playing around with it
At the moment the 3 things i am having trouble with that i wanted to achieve (and understand) were the blinking cursor, and the method for flawlessly putting the background (mine is a simple .png like a scroll) without the opaque overlapping the background.

Now i have a solution to the cursor blink as i played around with your code and it blinks too fast so i put in a wait command but it makes the whole text flash instead, realising this i think i am going to put an If statement for when you are not typing, so if no key is pressed then (and then do that if statement for making the cursor blink but with added wait commands). So just like the interface in DB pro and in this forum, when you type it simply puts a static | at the end of your letters till you stop for a moment then it blinks.

However i still cant make it view what i type as i type it and my code is now way too complicated to sucessfully make it work where i want it too so i obviously dont understand what its doing enough to put it in the right place because my code is near identical but still wont work, i know its because its in the wrong place due to the complexity of the rest of the function i put it in and not because i have typed anything wrong. I just cant follow the logic to where its going wrong. All it is doing when you left click the mouse in the right place is taking the characters as an input and either displaying them only as a whole when you press enter or making it flash the whole name very briefly, i just cant seem to put my finger on where it is not allowing me to see what i type as i type it, even though i can follow the logic in the simplified version.

For my 3rd problem which will be getting around the opaque txt issue because i dont want it drawling a great black line across my lovely scroll png my solution will be to copy part of the bmp and perhaps use it as a new image and paste this down just before displaying any new characters added to the string. Not sure how to go about this yet but ive not tried as i am still trying to get the rest to work.
I would love to display my code for the full 'character screen' function but it is far too much and too full of assets for it to work for anybody. I think i may just have to work on a completely new project building this up then trying to import it in, the only problem is i still have to put it in the right place within that function.

As for functions - i am already using them in abundance. I am not keen on gosub or goto and i prefer functions but i only really know how to use them as a gosub at the mo and not really how to return any value or string, i havent got that far just yet. I would love to know more about making it return a value as i am sure i could make use of it, perhaps a function that performs a mathmatical value based on some input then spits out the correct maths instead of constantly having to use the maths just to do something. I think i have the gist of it but anything more complicated than perhaps returning a number based on adding two numbers together or something is probably beyond me.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 24th Feb 2011 22:15
Ok i managed to condense everything else that is in that function (like plus and minus buttons to allocated spare points to one of 3 stats that grey out when you cant use anymore or go back to black when you can) and other things (like a back button to choose a character again and a finish button to save whatever values you chose for the stats then start the intro)

This is the extremely condensed version and i have cocked it up in 2 ways


1) Still doesnt display what your typing (really do not know where i am going wrong with this)

2) now keeps whatever you last typed and adds it onto the next. So click and type a name and it shows up at the end. Click again and type something else and it adds it to the string rather than replaces it.

Maybe i have spent too long on this and just cant see where i am going wrong but i feel like understanding this is important to know more about this language. Help would be greatfully accepted.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Feb 2011 11:44
The one major difference between my code example and yours is you turn SYNC ON. When SYNCing is on the screen only updates when it sees a SYNC so the GetText() function needs to have a SYNC within the DO/LOOP to see the text.

Quote: "2) now keeps whatever you last typed and adds it onto the next. So click and type a name and it shows up at the end. Click again and type something else and it adds it to the string rather than replaces it."


I'm not sure I get exactly what you mean. It's designed to keep the name so that when you type it, it remembers and starts the input with the last name used so the user can backspace and erase the old name. If that's not what you want you can clear the string every time by just making b$="" instead of b$=Tex$.

Quote: "Now i have a solution to the cursor blink as i played around with your code and it blinks too fast"


You can make another TIMER() for the prompt and make it blink at a specific time. The following blinks the prompt every 500 milliseconds (half a second).



Quote: "For my 3rd problem which will be getting around the opaque txt issue because i dont want it drawling a great black line across my lovely scroll png my solution will be to copy part of the bmp and perhaps use it as a new image and paste this down just before displaying any new characters added to the string. Not sure how to go about this yet but ive not tried as i am still trying to get the rest to work."


One issue you'll see is that copying just a bit of the background image may look ok but when the user goes beyond that area with text you'll want to either increase the size of the text clearing image or limit the amount of characters the user can type.

Quote: "I would love to know more about making it return a value as i am sure i could make use of it"


Basically you're already doing it with the GetText() function it's just a string. It gets user input and when the enter key is pressed it sends that string to the rest of the code with "ENDFUNCTION b$". Because the function call was "name=GetText()" whatever b$ was in the function is now name. Numbers are done the same way.



Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 26th Feb 2011 11:14
Quote: "I'm not sure I get exactly what you mean. It's designed to keep the name so that when you type it, it remembers and starts the input with the last name used so the user can backspace and erase the old name. If that's not what you want you can clear the string every time by just making b$="" instead of b$=Tex$."


I did want it to do that. So when you click a second time, it still keeps the name, positions the cursor at the end of that string so you can either add to or backspace from, what my problem is, is that bit wont overwirte the string i typed. So if for example i click in the box then type
Somawoopsispeltmynamewrong
That would appear, but clicking on it a second time then would delete the last characters but not update it real time, so when i finally got down to:
Soma
It would still have the whole old string there, then typing the rest:
arl
Would start to overwrite the old string but while still isplaying the old string causeing letters to overlap each other.

I tried putting random syncs here and there to update it but to no avail. Not really sure where im going wrong. Also just for the sake of it i tried to erase the whole string on clicking in the mousebox just to see if it would and even using name = "" or b$ = "" neither seem to delete the name (not that that is what i want to end up with as i said above but surely a "" in the right place would completely clear the string, how come i cant even do that if i wanted to?)
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Feb 2011 11:23 Edited at: 26th Feb 2011 11:24
I know you don't want to upload your whole project but you may have to so I can help you solve those issues. You can attach a .zip file with all the files needed. Or just post the code and I'll rem off any non-vital media.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 26th Feb 2011 13:00 Edited at: 26th Feb 2011 13:04
Ok, i have had moderate success with not only making it type what i want where i want, but also refreshing it correctly. It is very very messy and overlaps itself and allsorts underneath the paste image that i cut out of the segment of the background but do to a bit of fiddling it actually works exactly how i want it to. I would like someone to take a look at this later and tell me how i could make it less messy or more efficient but i will not post that code right now, i will save that for later.

I started working back on making the cursor blink at a normal speed when no key is pressed and the blink positioned at the end of the current string updated in real time to what you were typing. My theory for doing this involved using your simple keyblink using milliseconds as a timer grog, mixed with an if statement to only do it when no key is pressed. This is what i have so far but it really does not work and i think i may have seriously overcooked it.



Now, bare in mind that it also now doesnt auto update aswell because i condensed the code best i could just to make the cursor blink where i wanted to and how fast i wanted it to but i think reimporting it back into my main code i could get that working again. So ive not only gone and screwed up the overwrite system but also pressing enter seems to delete everything. I obviously dont know enough about this yet to fully understand but i have been let down by the vendor who was supposed to deliver my book this week so i have no references or decent tutorials that go into any great depth on string manipulation whilst still being in enough english in a way that you could teach to a child.

Rant here:


I have added a ton of commenting so you know what i think things are and what i was trying to achieve, hence it looks messier than it will be.
So where have i gone wrong on this, what is the best way of doing this?

Again another edit: sorry, my second to last post issue has been resolved, i know the above code messes it up again but i did fix it in the end. Ill post that up later to see how i could make it neater or if that is the best way. For now the only thing im stuck on is the blinking. The i also want to add a maximum string length but i think im going to try and attempt this first on my own.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Feb 2011 23:33 Edited at: 26th Feb 2011 23:36
Quote: "I started working back on making the cursor blink at a normal speed when no key is pressed and the blink positioned at the end of the current string updated in real time to what you were typing. My theory for doing this involved using your simple keyblink using milliseconds as a timer grog, mixed with an if statement to only do it when no key is pressed. This is what i have so far but it really does not work and i think i may have seriously overcooked it."


That's why it's better to keep it simple because when you don't it makes it much harder to do the same thing.

This line needs to change:


That function isn't being called at all because checking for KEYSTATE(0) does not work for non-detection of keys. To detect no keys being pressed we use the SCANCODE() command. But I'm going to remove the SCANCODE() part to work in a different way.

The LEN() command returns the amount of characters in a string. If the string was "Hello my name is Grog." the LEN() of that string would be 22. The only way to determine the horizontal size of the string is to use the TEXT WIDTH() command which looks at the current font and size to calculate just how many pixels wide that string would take up on the screen. So to determine where the prompt would be if you want to make the prompt by itself you need to calculate: Starting X coordinate of text + TEXT WIDTH() of the string. In this case it would be "x = 200 + TEXT WIDTH(b$)". So when you call the function with the LEN() command there's really no need for the function to know that because it's not useful for placing the prompt. It would be better to call the function with the starting x coordinate for the text and b$ so the x coordinate of the prompt can be determined. Calling the function with P$ isn't needed at all because the function itself is going to place the prompt. So that problem line in the above code snip should be changed to this:


Inside the function the "PTim=TIMER()" needs to be removed because that function goes so fast it'll never show anything since the timer is set and reset before 500 milliseconds are up. The best way to do it is to define it as GLOBAL at the beginning of your code so it retains it's value inside functions.


I'm leaving the IF/THEN check for the timer as is but it's best not to lock it into a DO/LOOP. If you want to force the prompt to show while keys are being typed it's best to put that after the IF/THEN check for the timer but use SCANCODE() as mentioned above to check for anything higher than zero (which means the user is hitting a key). Showing the prompt should be last right before leaving the function. Also there's no need to send anything back from the function.

Here's all the changes:


If you haven't already seen them check out TDK's Tutorials:
http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 27th Feb 2011 11:55 Edited at: 27th Feb 2011 12:53
Ok here is the working code for the character sheet so far, its not including the blinking cursor because honestly, i cant get it to work, it either blinks rapidly and seems to miss blinks out (no matter what values i change) or doesnt seem to blink at all so im leaving that for now but it just frustrated me that my theory didnt work. I mean it should with the right syntax (ilke not using keystate(0) but scancode instead, but it doesnt. When no key is pressed, print "|" at the end of the string, then if the end of the string = "|" then wait for a moment and change it to " ", then wait for a moment and repeat until a keystroke is pressed. But ahhh well, i guess even something as simple as that is a little beyond me for the time being, i got an email about my book and i should get it by tuesday so maybe ill learn something in there that will show me the error of my ways
I checked out TDK's tutorials (i have them bookmarked) and they are excellent but seem to have massive gaps in them if you were using them as a step guide, so they are (in my opinion) not for absolute beginners - except of course for the first one. What i need is that little transition between absolute beginner and beginner. I really dont need to know what a variable is any more or how to make it add a+b = c yet with many tutorials its all of a sudden BAM, sprites. 2 pages and your done. Not many code examples or the ins and outs of whats going on line by line its just a case of here type this in this is how you do pong with about 10 lines of comments and the rest is code. Best way to be with me is treat me like a 5 year old (always asking why, why, why at the end of every sentence ) its how i learn. They are nice tutrorials though and now ive got past the absolute beginners stuff i would like to look at them again to see if there is anything i can now get stuck into.

Anyway, here is my working character sheet name code, can anyone take a look and see if there is anything else i might have done to make it neater or any other ways so i may learn a little more about what ive done. I mean this does work but i cant help thinking it might not be the best way. Take a look and judge me



Its nearly there, and i have learned so much while doing this (thanks mainly to grog) so it has been a worthwhile venture trying to get this to work. When mixed in with my select character and then the character sheet loaded properly with my three stats and ability to select and deselect points and such forth it looks alright, plus it has taught me a lot.

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 28th Feb 2011 23:36 Edited at: 28th Feb 2011 23:44
I looked at your code and made some changes.

I moved the font change and size to outside of the do loop. When you change the font there's no need to change it over and over again (what it does within the DO/LOOP). The text for "Enter Your Name:" was also moved outside of the DO/LOOP because if it doesn't change positions there's really no need to do that over and over again either. To prevent having to repeat text writing I added a GET IMAGE to grab the modified image (the background with the text). Doing it that way makes it a lot easier... especially if you're going to do it a lot (as with most character sheets). Grabbing just a small area for one text box wouldn't help for the next text box you make (unless you want 15 to 20 small images pasted all over the screen to clear text) so it's best to just use the whole background to clear any text you may have on the screen. I also moved the text over a bit to make room for larger names.

I made the area you detected the mouse at a bit bigger (the area around the text and across the whole screen) and changed it back to MouseX (upper left corner), MouseY (upper left corner), MouseX (lower right corner), MouseY (lower right corner). It's best to keep a check for mouse coordinates the same way you would create a BOX so it's easy to read. That's basically what you're doing anyway... making an imaginary box and what better way to make a box than exactly how the BOX command does it.

I added the prompt and clearing it after the enter has been pressed.



Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 1st Mar 2011 00:10
Excellent, thanks for those tips. And i must have been doing something wrong with the blinking cursor because when i did it, it was way way too fast, that is just right. I will attempt to 'port' that into my main code and see what happens if i get a bit of time tomorrow, and i will keep your tips in mind.

The reason the set text size is all over the show is the other parts of my character sheet use different sizes for different lines but i will see if i can neaten that up a little and call it fewer times.

I didnt know that get image was more like a screenshot, i didnt think it would take the whole display (within the box perameters) in mind. I thought it just took a portion of the image you define and that was that. Hence why i always put it first then typed text over it because i thought it would paste over the top of it if you reversed the order. Now that i know this i can bare that in mind also when doing other things. Thanks a million Grog. If i had any gold stars id dish a few out to ya

Now i'd like to move onto sprites and get a mini game up and running to go with it (as so far its proving an okay way to learn) as ive done a tiny bit from snippets on sprite and animations in tutorials i have found but not seen anything nice and comprehensive just yet if anyone has any ideas on not just where to start, but where to carry on to. Either that or ill just wait for my 'hands on pro' book as it should be here tomorrow.

Login to post a reply

Server time is: 2024-11-23 03:07:31
Your offset time is: 2024-11-23 03:07:31