Jump to content

Possible: Mafia Wars like game Java Applet?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1
Auxcil

Auxcil

    Newbie

  • Members
  • PipPip
  • 23 posts
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 ^^

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
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.

#3
Auxcil

Auxcil

    Newbie

  • Members
  • PipPip
  • 23 posts
-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

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
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.

#5
Auxcil

Auxcil

    Newbie

  • Members
  • PipPip
  • 23 posts
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?

#6
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
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.

#7
Auxcil

Auxcil

    Newbie

  • Members
  • PipPip
  • 23 posts
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?

#8
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts

Quote

Java Application that modifies a .txt file? or Do you know a good way?
I don't really get this part of your question.

A SQL-database seems convenient. You can connect to it, get and set data with help from JDBC.

Quote

How to create 1?
I'm not 100% sure :D i'll have to look at it, when i'm on a pc with sql stuff installed and see what their software provides me.


The final part in this tutorial seems to combine an applet with a database: Lesson: JDBC Basics (The Java™ Tutorials > JDBC™ Database Access)

#9
Auxcil

Auxcil

    Newbie

  • Members
  • PipPip
  • 23 posts
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 ^^

#10
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
Ye, i don't think you can create the database with only Java. Once it's finished its content can be managed tho.

#11
farrell2k

farrell2k

    Learning Programmer

  • Members
  • PipPipPip
  • 60 posts
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.

#12
Guest_blairgo_*

Guest_blairgo_*
  • Guests

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.
Thank you for your comment, i like it.