SHOW:
|
|
- or go back to the newest paste.
| 1 | function retrodemo() | |
| 2 | symtable = system_load("scripts/symtable.lua")();
| |
| 3 | games = list_games({target = "snes"});
| |
| 4 | ||
| 5 | if (#games == 0) then | |
| 6 | shutdown("empty database, can't proceed.");
| |
| 7 | return; | |
| 8 | end | |
| 9 | ||
| 10 | game_1 = launch_target( | |
| 11 | games[math.random(#games)].gameid, | |
| 12 | LAUNCH_INTERNAL, | |
| 13 | game_callback | |
| 14 | ); | |
| 15 | ||
| 16 | game_2 = launch_target( | |
| 17 | games[math.random(#games)].gameid, | |
| 18 | LAUNCH_INTERNAL, | |
| 19 | game_callback | |
| 20 | ); | |
| 21 | ||
| 22 | move_image(game_2, VRESW * 0.5, 0); | |
| 23 | show_image({game_1, game_2});
| |
| 24 | end | |
| 25 | ||
| 26 | function game_callback(source, status) | |
| 27 | if (status.kind == "resized") then | |
| 28 | - | resize_image(source, VRESW * 0.5, VRESH * 0.5); |
| 28 | + | resize_image(source, VRESW * 0.5, VRESH); |
| 29 | end | |
| 30 | ||
| 31 | keymap = {};
| |
| 32 | keymap["w"] = "PLAYER1_UP"; | |
| 33 | keymap["s"] = "PLAYER1_DOWN"; | |
| 34 | keymap["d"] = "PLAYER1_LEFT"; | |
| 35 | keymap["a"] = "PLAYER1_LEFT"; | |
| 36 | keymap["d"] = "PLAYER1_RIGHT"; | |
| 37 | keymap["1"] = "PLAYER1_START"; | |
| 38 | keymap["LCTRL"] = "PLAYER1_BUTTON1"; | |
| 39 | keymap["LALT"] = "PLAYER1_BUTTON2"; | |
| 40 | ||
| 41 | function retrodemo_input(input) | |
| 42 | if (not input.translated) then | |
| 43 | return; | |
| 44 | end | |
| 45 | ||
| 46 | local key = keymap[ symtable[input.keysym] ]; | |
| 47 | ||
| 48 | if (key ~= nil) then | |
| 49 | input.label = key; | |
| 50 | target_input(game_1, input); | |
| 51 | target_input(game_2, input); | |
| 52 | end | |
| 53 | end |