My feed
Premium

Please
or
to access all these features

Geeky stuff

Pygame/Python assistance needed

1 reply

BarbaraManatee · 17/09/2015 18:53

I'm trying to design my first game. It seems like it should be ridiculously simple but I'm getting myself confused. I want it to show a picture of a letter & to wait for DS1 to press the corresponding letter on the keyboard. If he gets it right, it should show up another congratulatory picture before continuing on to another letter, else it should stay on the picture until he gets it right.

I've designed the pictures & brought them into the program. At the moment I've got them as a list to iterate over but I'm wondering if it wouldn't be better to have them in a dictionary with the corresponding K_ linked to the picture. Could I then make a function with the dictionary key & value as the inputs?

I've done a few Python tutorials but this is my first experiment with Pygame in an attempt to figure out what I can do with my new Python knowledge... it's not going well! GrinBlush

OP posts:
Report
cdtaylornats · 17/09/2015 22:34

What do you want the function to do?

Using a dictionary indexed by the letter seems ok. The problem using the dictionary is that pressing letter 'a' would always get the picture associated with it in the dictionary. You could continue keep the pictures in a dictionary indexed by a number and generate a random number to display the reward picture.

for example

loop until exit

{

pick random letter to show

show letter

read keypress

if keypress = displayed letter
{
generate random number
display picture corresponding to random number
wait
}
else take error action

}

Report
Please create an account

To comment on this thread you need to create a Mumsnet account.