• Post Reply Bookmark Topic Watch Topic
  • New Topic

New to coding but have a game based question about databases  RSS feed

 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i was to write a game like mincraft or 7 days where it involves crafting. over the times of learning to code i want to build a database of the items i will have in my games database. what would the best program or software be to write the data in so in the future it could be incorporated into a game.
 
Carey Brown
Saloon Keeper
Posts: 3251
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should make a class or classes that embody "persistence". You can start out by persisting to a file. As an example, a text file with name/value pairs, or a text file that contains JSON formatted text. You could make a binary file using serialized objects. And, finally, you could use a database. Having a "persistence" layer would allow you to swap out your persistence approach without affecting your core program logic, so you could start out with the easiest thing to implement and replace it later when the need arises.

You might want to look up how to create DAO (Data Access Objects) because they would be key to separating core logic from persistence.
 
Campbell Ritchie
Marshal
Posts: 56221
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Tim Cooke
Marshal
Posts: 3958
234
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mitchell, welcome to the Ranch!

You might have missed our rules about cross posting. We allow it, but we ask that you BeForthrightWhenCrossPostingToOtherSites.

Cross posted: http://www.javaprogrammingforums.com/cafe/45759-new-coding-but-have-game-based-question-about-databases.html
 
salvin francis
Saloon Keeper
Posts: 1644
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my idea:

Table : Items
Table : Combinations
Table : Crafting

Items:

Item Id | Name
0 | Stone
1 | Stick
2 | pickaxe


Combinations:
Combination Id | Item Id | Grid Location
0 | 0 | 0,0
0 | 0 | 1,0
0 | 0 | 2,0
0 | 1 | 1,1
0 | 1 | 2,1


Crafting:
CombinationId | ItemId
0 | 2




 
salvin francis
Saloon Keeper
Posts: 1644
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To those new to the concept. Minecraft gives you a 3x3 grid to place items.

[ ] [ ] [ ]
[ ] [ ] [ ]
[ ] [ ] [ ]


So, I just created a table to keep this data

[X] [X] [X]
[ ] [Y] [ ]
[ ] [Y] [ ]


where X = stone, and Y = stick would create a pickaxe

Basically you can add additional items and combinations later
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!