一些控制器共享公共佈局但具有不同的面,即360和PS3(X是A,三角形是Y等)。有了戰鬥棒,飛行棒,吉他等額外的外圍設備 - 它們只是映射到控制檯期望的不同面孔。由於按鈕通常是在任何控制器均勻成型之前定義的,因此您也可以這樣做。
每個映射並不都適用於每個控制器,因此它可能不是理想的 - 考慮到現代控制檯控制器,它應該沒問題。如果您添加Intellivision控制器和鍵盤/鼠標,事情可能會變得很奇怪。
// using CHAR(8) for absolutely no good reason. change at will.
CREATE TABLE button_maps (
id tinyint unsigned not null auto_increment,
map_id char(8) not null,
primary key (id),
unique key map_id (map_id)
);
INSERT INTO button_maps (map_id)
VALUES
// dual analog, any direction
('ANA_LFT'), ('ANA_RT'),
// 4-button compass face
('BT_N'), ('BT_S'), ('BT_E'), ('BT_W'),
// shoulder buttons
('BT_LT1'), ('BT_LT2'), ('BT_RT1'), ('BT_RT2'),
// system buttons
('BT_START'), ('BT_SEL'), ('BT_MENU'),
// analog stick click-in, usually called "L/R 3"
('ANA_L3'), ('ANA_R3'),
// 8-direction d-pad - add clockface points for both analogs too
('DPAD_N'), ('DPAD_S'), ('DPAD_E'), ('DPAD_W'),
('DPAD_NW'), ('DPAD_NE'), ('DPAD_SW'), ('DPAD_SE'),
// and DS stylus so it's not obvious what I'm looking at right now
('STL_TAP'), ('STL_DTAP'), ('STL_DRAG'),
// and so on
注:我不知道如何將這些全身運動控制事物內部處理,祝你好運如果你有對付他們。 LFOOT_HOKEYPOKEY
什麼的。
注意2:嚴重的是,不要在那裏使用char(8)。獲取詳細信息,但保持一般,足以應用於通用控制器風格而不是品牌。
現在每每個品牌控制器的按鈕,與他們的名字(假定爲「控制器」表):
CREATE TABLE buttons (
id tinyint unsigned not null auto_increment,
controller_id tinyint unsigned not null references controllers.id,
map_id tinyint unsigned not null references button_maps.id,
button_name varchar(32) not null,
primary key (id),
unique key controller_map (controller_id, map_id)
);
INSERT INTO buttons (controller_id, map_id, button_name)
VALUES
(2, 1, 'Left Analog'), (2, 2, 'Right Analog'),
(2, 3, 'Y'), (2, 4, 'A'), (2, 5, 'B'), (2, 6, 'X'),
(2, 7, 'Left Trigger (LT)'), (2, 8, 'Right Trigger (RT)'),
(2, 9, 'Left Bumper (LB)'), (2, 10, 'Right Bumper (RB)')
// and so on. PS3 with button shapes and R1/2, L1/2 instead of trigger/bumper
現在,對於操作按鈕按壓(或多個按鈕,或者序列)表示到遊戲。這沒有考慮上下文(原始問題的2 & 3),例如遊戲模式或替代按鈕配置,但Josh Smeaton和littlegreen已經涵蓋了這一點。
這定義了每個單獨遊戲的動作,這不是非常有效。通過添加一個通用的遊戲「類型」層,您可能會顯着地壓縮事物。許多在某種流派/視角內的遊戲都有共同的控制,並且它只是變得越來越普遍(控制檯FPS添加了預定義的Halo和CoD風格的按鈕配置,因爲玩家知道它們等等)。因此,如果您可以根據每種流派定義一組常用操作,並且僅根據需要使用這些操作來覆蓋/擴展這些默認設置,那麼您可能可以獲得更乾淨的解決方案。
首先,定義每一個動作:
CREATE TABLE game_actions (
id int unsigned not null auto_increment,
game_id int unsigned not null references games.id,
action varchar(32) not null,
primary key (id)
);
INSERT INTO game_actions (game_id, action)
VALUES (1, 'Shoot'), (1, 'Reload'), (1, 'Turn Left'), (1, 'Turn Right')
// and so on
最後,定義與每個動作相關的按鈕按下。 「序數」字段用於組合序列,如格鬥遊戲組合 - 單個動作是0次序,序列從1開始計數,只是爲了使它們易於區分。它沒有考慮時間,所以你可能需要一個「無」按鈕作爲一些更復雜的組合遊戲(Soul Caliber等)的休息。
CREATE TABLE game_action_buttons (
id int unsigned not null auto_increment,
game_action_id int unsigned not null references game_actions.id,
ordinal tinyint unsigned not null,
button_map_id tinyint unsigned not null references button_maps.id,
primary key (id)
);
INSERT INTO game_action_buttons (game_action_id, ordinal, button_map_id)
VALUES
(1, 0, 8), // right trigger to shoot
(2, 0, 6), // west face button (X/square) to reload
(3, 0, 7), (3, 0, 9) // combo: both bumpers for rear view look-back while driving
// and a Street Fighter shoryuken on the d-pad to show a sequence:
(4, 1, 21), // DPAD_E: right
(4, 2, 20), // DPAD_S: down
(4, 3, 26), (4, 3, 4) // DPAD_SE + BT_S: down/right + fierce... i think.
(免責聲明:。!我創建了一個遊戲工作室我在工作了類似的數據庫不完全一樣,但足以使我那種故意留下了很多了類似對不起我希望這足夠與Kickstart一些想法雖然,這是一個有趣的問題。)
這是一個非常酷的設計問題。 :)無論如何,優雅地做它! – Matt 2010-10-16 02:34:50
偉大的問題! – 2010-10-16 04:01:57