Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Roll 'n' Jump 

2# Written in 2020, 2021 by Samuel Arsac, Hugo Buscemi, 

3# Matteo Chencerel, Rida Lali 

4# To the extent possible under law, the author(s) have dedicated all 

5# copyright and related and neighboring rights to this software to the 

6# public domain worldwide. This software is distributed without any warranty. 

7# You should have received a copy of the CC0 Public Domain Dedication along 

8# with this software. If not, see 

9# <http://creativecommons.org/publicdomain/zero/1.0/>. 

10 

11"""Gestion des commandes.""" 

12 

13from os.path import join 

14import rollnjump.conf as cf 

15import rollnjump.utilities as ut 

16import rollnjump.menu as mn 

17import rollnjump.player as plyr 

18 

19FILE = join(cf.CONFDIR, "commands.txt") 

20"""Fichier des commandes""" 

21 

22TEXTCAPT = { 

23 "fr": "Capture de la touche pour le joueur : ", 

24 "en": "Key capture for player : " 

25} 

26 

27 

28def init_com(): 

29 """Initialiser le fichier des commandes.""" 

30 with open(FILE, "w") as empty_com: 

31 empty_com.writelines([ut.keyname(key) 

32 + "\n" for key in plyr.JUMP_KEYS]) 

33 

34 

35def get_keys(): 

36 """Récupère les commandes sauvegardées par les utilisateurs.""" 

37 with open(FILE) as coms: 

38 plyr.JUMP_KEYS = [ut.keyidentifier(i) 

39 for i in coms.read().splitlines()] 

40 

41 

42def set_keys(keys): 

43 """ 

44 Changer les commandes du jeu. 

45 

46 Parameters 

47 ---------- 

48 keys : int list 

49 Liste des commandes 

50 """ 

51 plyr.JUMP_KEYS = keys 

52 with open(FILE, "w") as coms: 

53 coms.writelines([ut.keyname(key) 

54 + str("\n") for key in plyr.JUMP_KEYS]) 

55 

56 

57Modify_size = (100, 100) 

58Modify_pos = [(900, 85 + i * 150) for i in range(cf.NB_PLAYERS_MAX)] 

59Modify_idle = "modify.png" 

60Modify_hover = "modifypushed.png" 

61modifybutton = [] 

62"""Liste des boutons de modification.""" 

63for i in range(cf.NB_PLAYERS_MAX): 

64 modifybutton.append( 

65 mn.ButtonImage( 

66 Modify_pos[i], 

67 Modify_size, 

68 Modify_idle, 

69 Modify_hover 

70 ) 

71 )