Instead of quering the database multiple times, I was thinking of querying it once and storing all the values in an array. Theres 2 ways I've been thinking of setting it up, I'm wondering if there is a 'right way' to do it or both ways are acceptable. Also, which one you think will be the easier array to handle when dealing with multiple (for example 100) entries
I will use weapons as an example. Say a player has a lot of weapons in his inventory, and they all have stats. Those stats are:
-Name
-Minimum Damage
-Maximum Damage
-Description
I am leaning towards the first idea, as it looks more organised, but would like to get some feedback! I've never really dealt with multidimensional arrays.
Array idea 1
The first idea I had was to make each weapon name an array and each stat of the weapon an index.
Array
(
[Name] => Array
(
[mindamage] => 3
[maxdamage] => 10
[Description] => "A blunt sword"
)
)
Array idea 2
The second idea was to make each index of the first array the name of each weapon stat, then each index inside of them a numeric array
Array
(
[Name] => Array
(
[0] => Blunt Sword
[1] => Steel Battleaxe
[2] => AK-47
)
[mindamage]
(
[0] => 3
[1] => 10
[2] => 200
)
[maxdamage]
(
[0] => 5
[1] => 18
[2] => 500
)
[description]
(
[0] => "A blunt sword
[1] => "A steel battleaxe"
[2] => "A machine gun
)
)
Creating a multidimensional array
Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
-
- Posts: 175
- Joined: Sun Oct 11, 2009 9:33 am
Return to “Advanced Help and Support”
Jump to
- General
- ↳ Announcements and Site Discussion
- ↳ News
- ↳ Say Hello
- ↳ Off-Topic
- ↳ Reviews
- ↳ Development Related
- ↳ Misc
- Developer's Corner
- ↳ General Development
- ↳ Game Design
- ↳ Resources
- ↳ Recruitment
- Game Development
- ↳ Beginner Help and Support
- ↳ Advanced Help and Support
- ↳ Programs/Assets/Libs/Open Source/Ect...
- ↳ Coding
- Show Off
- ↳ Project Showoff Tier I
- ↳ Project Showoff Tier II
- ↳ WebSite
- ↳ Art Showoff
- ↳ Members Games
- ↳ Main Empire Special
- ↳ General
- ↳ Development
- ↳ Off-Topic
- ↳ Bad Touch Studios
- ↳ Nitewing Gaming
- ↳ Fabled Kingdoms of Nizinia
- ↳ Announcements
- ↳ Development
- ↳ General
- ↳ Maze
- ↳ General
- ↳ Development
- ↳ Media
- ↳ Forsaken Sanctum 4.0
- ↳ General
- ↳ Contests
- ↳ Bugs and suggestions
- ↳ Forum Game
- ↳ Cavern Crawl
- ↳ Planetary Wars
- ↳ General
- ↳ Development
- Dot World Maker
- ↳ General
- ↳ Source Discussion
- New Worlds Engine
- ↳ General
- ↳ NWE Project Showoff
- KWM - Kal's world maker engine and NEAB
- ↳ Announcements
- ↳ KWM
- ↳ NEAB
- Tutorials
- ↳ Tutorials
- ↳ Epiales's Blender Tutorials
- ↳ Youtube Tutorials
- ↳ Browser Based MMO 2.0
- ↳ Real Time Browser Based MMO
- ↳ Older Browser MMO Videos
- ↳ Browser based RTS Videos
- ↳ C# Tutorials Videos
- ↳ Impact and Node/Socket.io
- ↳ Advanced MMO Framework
- ↳ Node For beginners
- ↳ Zester's Video Tutorials
- ↳ HallsNode
- ↳ Ticket System 2.0
- ↳ Code Sharing
- ↳ Hall's Games
- TMMOKit
- ↳ Help and Guides
- ↳ General
- Engine Discussion
- ↳ HTML5/Web Engines
- ↳ MMO Makers
- ↳ 3d Engines
- ↳ 2D engines
- ↳ Unity 3d
- ↳ General Unity
- ↳ Art and Assets
- ↳ Scripting/Coding
- Simple PBBG Engine
- ↳ Updates
- ↳ General
- Test