• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

New to coding but have a game based question about databases

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 9561
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 76419
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Marshal
Posts: 5409
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2908
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2908
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic