how create profiles
-
- Prole
- Posts: 4
- Joined: Thu Sep 03, 2009 12:25 pm
how create profiles
how do i create profiles for game and save profile.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: how create profiles
I'm afraid your question is not very clear.reza10203045 wrote:how do i create profiles for game and save profile.
Are you asking how to save data? For that, you need the love.filesystem functions.
Could you please elaborate? It's hard to help you otherwise.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: how create profiles
You'll need to code it yourself.
The input box for entering your name, the method for saving a file with the current game's data. I haven't implemented any of that yet as you would see if you tried my game. But I hope to try soon.
The name input part would be especially difficult as you'd have to run through a kind of loop waiting for key presses, figure out what key was pressed, add it to a string of characters pressed, if a backspace is pressed remove the last character. It's quite a mess. But when I get mine working, you'll be able to see it when I upload another demo.
The input box for entering your name, the method for saving a file with the current game's data. I haven't implemented any of that yet as you would see if you tried my game. But I hope to try soon.
The name input part would be especially difficult as you'd have to run through a kind of loop waiting for key presses, figure out what key was pressed, add it to a string of characters pressed, if a backspace is pressed remove the last character. It's quite a mess. But when I get mine working, you'll be able to see it when I upload another demo.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: how create profiles
Well, it wouldn't be so difficult if you use a GUI library.Jasoco wrote:The name input part would be especially difficult
Anyway, you can't use loops, it'll block the game completely. If you want your hands to get dirty, use game states.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: how create profiles
That's what I meant. Loops would freeze the game. I'm going to try implementing one by putting in a state called "inSetup" which will handle key presses and display the appropriate stuff.Robin wrote:Well, it wouldn't be so difficult if you use a GUI library.Jasoco wrote:The name input part would be especially difficult
Anyway, you can't use loops, it'll block the game completely. If you want your hands to get dirty, use game states.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: how create profiles
Here's a question though. How do I convert the code I get from love.key_press into the actual character?
Each key has a code that is recieved when a key is pressed. For instance, A is 97. B is 98. But there doesn't seem to be a way to differentiate between a capital and lowercase letter. I guess we can poll for Shift as well (Which is 104 and 103 for the Left and Right shift's) and deal with it accordingly.
Do I have to make my own chart to get the right letters? *sigh*
Each key has a code that is recieved when a key is pressed. For instance, A is 97. B is 98. But there doesn't seem to be a way to differentiate between a capital and lowercase letter. I guess we can poll for Shift as well (Which is 104 and 103 for the Left and Right shift's) and deal with it accordingly.
Do I have to make my own chart to get the right letters? *sigh*
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: how create profiles
I have a very rudimentary setup right now:
This function will return a letter or number. Only letters and numbers right now. All lowercase.
In your KeyPress function:
Then in your Draw function you use something like this:
Make sure you have a global variable first. I used tmpName to hold the name.
I haven't implemented backspace yet either. So don't go by me. This is just a starting prototype.
Edit: Making good progress. Will post all my code when I get it perfected.
This function will return a letter or number. Only letters and numbers right now. All lowercase.
Code: Select all
--RETURN LETTER FROM NUMBER
function returnChar(c)
local str = ""
if c > 96 and c < 123 then
local chr = "abcdefghijklmnopqrstuvwxyz"
local n = c - 96
str = string.sub(chr, n, n)
if c > 47 and c < 58 then
local n = c - 48
str = n
else
str = ""
end
if kShift then str = string.upper(str) end
return str
end
Code: Select all
tmpName = tmpName .. returnChar(k)
Code: Select all
love.graphics.drawf(tmpName, 100, 100, 640, love.align_center
I haven't implemented backspace yet either. So don't go by me. This is just a starting prototype.
Edit: Making good progress. Will post all my code when I get it perfected.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: how create profiles
keycodes are available in 0.6.0
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: how create profiles
Does 0.6.0 have ways to find out how wide a string of characters will be drawn at so we can figure out where to draw a cursor? If you create your own fonts, they could be any size, and any combination of characters could be any width. It's impossible to find out how wide the text is going to be so we can place a blinking cursor in the right place. We need some ways of finding out the dimensions of strings based on the font they're going to use. Like where the top left corner pixel will be at the end of a string of text. And it should have support for wrapped text too.
Basically it'd be something like:
Where 320 is the optional wrap value (in case the stringOfTxt is long enough it wraps a few lines) and the varTxtXY would be a local array that is returned containing the rightmost x and y points based on the string's length.
Would be verrrrry useful for making it look seamless.
Basically it'd be something like:
Code: Select all
love.graphics.setFont(fontName)
local varTxtXY = love.graphics.print(stringOfText, 320)
love.graphics.print(stringOfText, screenW / 2 - 50, screenH / 2, 320, love.align_left)
love.graphics.line(varTxtXY[0], varTxtXY[1], 0, 20)
Would be verrrrry useful for making it look seamless.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: how create profiles
Actually, this is possible in 0.5.0.
See http://love2d.org/docs/Font.html
See http://love2d.org/docs/Font.html
Help us help you: attach a .love.
Who is online
Users browsing this forum: No registered users and 9 guests