Slark Posted November 18, 2015 Report Share Posted November 18, 2015 sa zicem ca am facut in python sa apara in Command Prompt (Windows)o mapa de genu###############-----------------##-----------------##--------J--------##-----------------##-----------------###############iar acum eu vreau sa misc J de la tastatura cu W A S Dcare ii comanda sa citeasca ce apas la tastatura?sau nu exista asa ceva in (cmd)stiu ca in c++ erafolosesc python 3.5.0m-am uitat pe google dar nu am gasit mare lucru decat msvcrt.getch() dar nu imi dau seama cum functioneaza Quote Link to comment Share on other sites More sharing options...
Guest Posted November 18, 2015 Report Share Posted November 18, 2015 ce vrei sa faci cu j-ul? daca vrei sa faci un joculet poti incerca libraria pygame cu care o sa fie mult mai usor daca vrei sa faci un joc Quote Link to comment Share on other sites More sharing options...
Slark Posted November 18, 2015 Author Report Share Posted November 18, 2015 is la inceput.. nu vreau sa ma bag in librari (extra) vreau momentan sa o invat pe ce-a standardnu vreau sa fac nimic special..vreau sa stiu doar daca merge si daca da.. cum? Quote Link to comment Share on other sites More sharing options...
Active Members MrGrj Posted November 18, 2015 Active Members Report Share Posted November 18, 2015 Sunt mai multe solutii. Una dintre ele ar fi:- când apesi w interschimbi j cu - de deasupra lui si tot asa pt fiecare liter?(asd)- hints: ai o matrice. Tine minte pozitia initial? a lui j si tine cont de m?rimea matricei. Quote Link to comment Share on other sites More sharing options...
Slark Posted November 18, 2015 Author Report Share Posted November 18, 2015 Da MrGrj am idee cum trebuie facutdar nu vreau sa fac cu input cand pune w si apasa enter sa se mistevreau doar cand apasa w/a/s/d fara entersa il miste doar din w/a/s/dcare ii comanda? atat vreau sa stiu Quote Link to comment Share on other sites More sharing options...
Active Members MrGrj Posted November 18, 2015 Active Members Report Share Posted November 18, 2015 Python nu are implicit functionalitatea asta. Pe Windows poti folosi modulul msvcrt:import msvcrtprint 'Press a,s,d or w to move the object:\n'input_char = msvcrt.getch()if input_char == 'a': print 'Aici muti elementul la stanga' # faci asa si pentru restu' controalelor Quote Link to comment Share on other sites More sharing options...
Slark Posted November 18, 2015 Author Report Share Posted November 18, 2015 Mersi mult MrGrjnu a mers exact cum ai scris tu dar mi-am dat seama unde era bubaif input_char == b'a': trebuie sa pun inainte de 'a' (sau 'w', 's', 'd') cate un bimi poate explica cineva de ce apare cu b?sau care ii faza cu el? Quote Link to comment Share on other sites More sharing options...
bcman Posted November 18, 2015 Report Share Posted November 18, 2015 Cred ca o sa-ti mearga daca folosesti msvcrt.getwch()https://docs.python.org/2/library/msvcrt.htmlDaca vrei sa-ti mearga si pe altceva in afara de Windows: https://pypi.python.org/pypi/getch Quote Link to comment Share on other sites More sharing options...
pr00f Posted November 18, 2015 Report Share Posted November 18, 2015 imi poate explica cineva de ce apare cu b?sau care ii faza cu el?Python 3 https://docs.python.org/3.3/reference/lexical_analysis.html#string-literalsBytes literals are always prefixed with 'b' or 'B'; they produce an instance of the bytes type instead of the str type. They may only contain ASCII characters; bytes with a numeric value of 128 or greater must be expressed with escapes.Python 2 https://docs.python.org/2/reference/lexical_analysis.html#string-literalsA prefix of 'b' or 'B' is ignored in Python 2; it indicates that the literal should become a bytes literal in Python 3 (e.g. when code is automatically converted with 2to3). A 'u' or 'b' prefix may be followed by an 'r' prefix. Quote Link to comment Share on other sites More sharing options...
Active Members MrGrj Posted November 18, 2015 Active Members Report Share Posted November 18, 2015 (edited) Mersi mult MrGrjnu a mers exact cum ai scris tu dar mi-am dat seama unde era bubaif input_char == b'a': trebuie sa pun inainte de 'a' (sau 'w', 's', 'd') cate un bimi poate explica cineva de ce apare cu b?sau care ii faza cu el?Caracterul tau ( `a` ) trebuie tratat ca un byte string(asa trebuie), de aici si sintaxa:b'char' Edited November 18, 2015 by MrGrj Quote Link to comment Share on other sites More sharing options...
Slark Posted November 18, 2015 Author Report Share Posted November 18, 2015 Va multumesc.Se poate inchide Quote Link to comment Share on other sites More sharing options...