Like the title says, Is it possible to make a Mafia Wars type game as just a Java Applet embedded into a website?
I believe it could be done but all of what I have done has been applets that reload and don't save any information on the page closing.
Thanks ^^
Possible: Mafia Wars like game Java Applet?
Started by Auxcil, Jul 16 2010 12:44 AM
11 replies to this topic
#1
Posted 16 July 2010 - 12:44 AM
:compress: http://tinyurl.com/jmlsig1
|
|
|
#2
Posted 16 July 2010 - 01:21 AM
Why would you wait untill the user closes the page to begin saving? I'd allready update the Database as soon as the user buys something or attacks a bank or whatever mafia wars is like ^^
And if the stop( ) gets called when the user closes the browser it can be handled there to save whatever needs to be saved in the end.
And if the stop( ) gets called when the user closes the browser it can be handled there to save whatever needs to be saved in the end.
#3
Posted 16 July 2010 - 01:27 AM
-facepalm- I knew that. Brains off this late...
How would I save peoples info though? i guess thats the real questions/problem I have. All of my work in Java so far has been Small single applications.
All I want to use for this is HTML and Java Applets
How would I save peoples info though? i guess thats the real questions/problem I have. All of my work in Java so far has been Small single applications.
All I want to use for this is HTML and Java Applets
:compress: http://tinyurl.com/jmlsig1
#4
Posted 16 July 2010 - 01:37 AM
Store it in the databank in a table "Users" or something. I assume users will have to login or something at first?
If there is no logging in,i think you must use cookies and put data (some kind of primary key for the info you need) in there that can be used to get the right info out of the DB when the user accesses the applet again.
edit:
I would give almost every table a column "userId". Then you can access the right stuff for the right user. The userId can be looked up by the users login details. Or if it's without logging in, you store the userId in the cookie and retrieve it there.
If there is no logging in,i think you must use cookies and put data (some kind of primary key for the info you need) in there that can be used to get the right info out of the DB when the user accesses the applet again.
edit:
I would give almost every table a column "userId". Then you can access the right stuff for the right user. The userId can be looked up by the users login details. Or if it's without logging in, you store the userId in the cookie and retrieve it there.
#5
Posted 16 July 2010 - 01:50 AM
Logging in is what we are shooting for, so people can play wherever they are.
Got an idea/example of how I would save/get the info?
Got an idea/example of how I would save/get the info?
:compress: http://tinyurl.com/jmlsig1
#6
Posted 16 July 2010 - 02:07 AM
Let there be a register frame somewhere where the user fills in at atleast a username and password. Put those 2 in the DB, and every object the user creates / every record that is inserted in the DB from that user will have a foreign key to the unique userID
USER table should have at least:
(user)id
username
password
All other tables like ...ehm.. inventory will have the userId as foreign key
userId ->FK to USERS
weapon -> FK to weapons table
amount int
So to display the inventory of this specific user you only need to find out his userID.
(SELECT * FROM Inventory WHERE userId = variable)
to get the userId, he should log in at the start of the applet.
Start the applet with only 2 textboxes to log in. When the user submits. get the password that goes with the username from the DB. It's probably hashed / secured in some way. So hash/secure the password the user gave in too. Compare the 2 hashed/secured passwords. If they are equal set a variable userId to the userId from the DB.
USER table should have at least:
(user)id
username
password
All other tables like ...ehm.. inventory will have the userId as foreign key
userId ->FK to USERS
weapon -> FK to weapons table
amount int
So to display the inventory of this specific user you only need to find out his userID.
(SELECT * FROM Inventory WHERE userId = variable)
to get the userId, he should log in at the start of the applet.
Start the applet with only 2 textboxes to log in. When the user submits. get the password that goes with the username from the DB. It's probably hashed / secured in some way. So hash/secure the password the user gave in too. Compare the 2 hashed/secured passwords. If they are equal set a variable userId to the userId from the DB.
#7
Posted 16 July 2010 - 02:42 AM
Ok, that I get now. But what language am I using to make the database? Java Application that modifies a .txt file? or Do you know a good way?
:compress: http://tinyurl.com/jmlsig1
#8
Posted 16 July 2010 - 05:24 AM
Quote
Java Application that modifies a .txt file? or Do you know a good way?
A SQL-database seems convenient. You can connect to it, get and set data with help from JDBC.
Quote
How to create 1?
The final part in this tutorial seems to combine an applet with a database: Lesson: JDBC Basics (The Java™ Tutorials > JDBC Database Access)
#9
Posted 16 July 2010 - 06:56 AM
My first question was if it was possible to do this with JUST Java Applets and HTML, I'm starting to see it is not....
Thanks for all your help ^^
Thanks for all your help ^^
:compress: http://tinyurl.com/jmlsig1
#10
Posted 16 July 2010 - 08:00 AM
Ye, i don't think you can create the database with only Java. Once it's finished its content can be managed tho.
#11
Posted 19 July 2010 - 03:30 AM
I suppose you could use a property file for each user.
Properties (Java Platform SE 6)
An sql database is probably the best way to do what you want, but you could use a master username/pass text file to authenticate users, then use a properties file that contains user info such as inventory, money, etc.
Do you know anything about simple game programming in Java? I'd start there before even attempting anything as complicated as this.
Properties (Java Platform SE 6)
An sql database is probably the best way to do what you want, but you could use a master username/pass text file to authenticate users, then use a properties file that contains user info such as inventory, money, etc.
Do you know anything about simple game programming in Java? I'd start there before even attempting anything as complicated as this.
#12
Guest_blairgo_*
Posted 19 July 2010 - 11:52 PM
Guest_blairgo_*
oxano said:
Let there be a register frame somewhere where the user fills in at atleast a username and password. Put those 2 in the DB, and every object the user creates / every record that is inserted in the DB from that user will have a foreign key to the unique userID
USER table should have at least:
(user)id
username
password
All other tables like ...ehm.. inventory will have the userId as foreign key
userId ->FK to USERS
weapon -> FK to weapons table
amount int
So to display the inventory of this specific user you only need to find out his userID.
(SELECT * FROM Inventory WHERE userId = variable)
to get the userId, he should log in at the start of the applet.
Start the applet with only 2 textboxes to log in. When the user submits. get the password that goes with the username from the DB. It's probably hashed / secured in some way. So hash/secure the password the user gave in too. Compare the 2 hashed/secured passwords. If they are equal set a variable userId to the userId from the DB.
USER table should have at least:
(user)id
username
password
All other tables like ...ehm.. inventory will have the userId as foreign key
userId ->FK to USERS
weapon -> FK to weapons table
amount int
So to display the inventory of this specific user you only need to find out his userID.
(SELECT * FROM Inventory WHERE userId = variable)
to get the userId, he should log in at the start of the applet.
Start the applet with only 2 textboxes to log in. When the user submits. get the password that goes with the username from the DB. It's probably hashed / secured in some way. So hash/secure the password the user gave in too. Compare the 2 hashed/secured passwords. If they are equal set a variable userId to the userId from the DB.


Sign In
Create Account


Back to top









