sugarlabs / river-crossing-activity

River Crossing Activity for sugar desktop
0 stars 1 forks source link

Keyboard Controls #5

Open marsian83 opened 3 months ago

marsian83 commented 3 months ago

I have made it so that farmer faces moving direction and also keyboard inputs also I have added Can you check @chimosky

chimosky commented 3 months ago

Tested, left a comment in one of the commits.

The farmer turns, but the boat doesn't. The turn should be both.

marsian83 commented 3 months ago

I have changed the Flipping and keyboard inputs

chimosky commented 3 months ago

Tested, the boat flips and the farmer flips but the farmer is still in the same position as before which isn't how it should work.

The game starts out with him on the left, when the boat flips, he should be on the right as he flips, and the arrow buttons work but we still have to click to drop-off anything in the boat, this could be achieved with the spacebar.

Why are the events being stored instead of processed as they occur?

marsian83 commented 2 months ago

added spacebar action and made the held entity and farmer switch positions

Why are the events being stored instead of processed as they occur?

The reason I have to do that is if I process pygame.events using pygame.events.get once, I can't call them on the same frame once again as that gives an empty array I already have to call it in main.py in order to check for QUIT event, so I store it at the same time so any screen can use the same events by calling game.events at most this might only introduce a 1 frame delay but is neccessary

chimosky commented 2 months ago

added spacebar action and made the held entity and farmer switch positions

Tested, if spacebar is pressed before any key then the game freezes and no other key event is handled.

The logs show this;

Traceback (most recent call last):
  File "/home/ibiam/Activities/river-crossing-activity/main.py", line 103, in run
    self.update_function()
  File "/home/ibiam/Activities/river-crossing-activity/views/game.py", line 289, in update
    boat_click_action()
  File "/home/ibiam/Activities/river-crossing-activity/views/game.py", line 85, in boat_click_action
    define_objects(left=left)
  File "/home/ibiam/Activities/river-crossing-activity/views/game.py", line 116, in define_objects
    obj = Obj(gap * (i + 1) + land_object_width * i,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

The reason I have to do that is if I process pygame.events using pygame.events.get once, I can't call them on the same frame once again as that gives an empty array I already have to call it in main.py in order to check for QUIT event, so I store it at the same time so any screen can use the same events by calling game.events at most this might only introduce a 1 frame delay but is neccessary

Have you looked at pygame.event.poll()? It does this.

marsian83 commented 2 months ago

event.poll is behaving weird, fails to catches events sometimes, especially key presses I don't know if I'm using it incorrectly I think it behaves same as event.get where if consumed the event is getting exhauseted

marsian83 commented 2 months ago

I have fixed the boat clicck bug

chimosky commented 2 months ago

event.poll is behaving weird, fails to catches events sometimes, especially key presses I don't know if I'm using it incorrectly I think it behaves same as event.get where if consumed the event is getting exhauseted

It basically gets an event from the queue, if it doesn't behave as intended then you can leave it.

chimosky commented 2 months ago

Tested 452134f, works as expected.

When the sheep is on the boat, clicking on the leg seems to be the only way to drop it, this is besides the spacebar. Clicking on other parts of the goat seems to have no effect.

marsian83 commented 2 months ago

Oh, I noticed that I tried fixing this but it appears to be an issue rooted in something I was unable to find, can you help me with this? or if it is not too noticeable maybe we can ignore it

chimosky commented 2 months ago

I can take a look later.

marsian83 commented 2 months ago

I have updated the icon for this activity as well so that it adapts to Sugar colors. After you take a look at the sheep leg issue, We can also make a release for this activity.

chimosky commented 1 month ago

I haven't been able to take a look into this, not sure I can at the moment.

marsian83 commented 1 month ago

so can we package and release the activity? honestly, I do not reckon this issue would be noticeable to players

chimosky commented 1 month ago

Yes we can package and release it, see our maintainer check list. Make a list of the activities and their repos, we'll also need to transfer them to the Sugar Labs org.

I can handle uploading them to aslov4 after you make the releases.