New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapt to display size #25
Conversation
|
In all the commits above +45 is used to center the activity. The hard coded coordinates were wrongly determined. I determined the +45 shift by using the loaded image dimensions. I have two options-
However, I feel declearing a global variable does not add to code readability for the future (in this case). This shift should have been acounted for while using direct coordinates for 1280*720 display and adding it as another variable will make the code more complicated to understand. So I just added it in the commit message instead. What do you suggest @quozl @chimosky @srevinsaju ? |
|
I suggest you to use a variable called I would suggest
by priority, you may like to choose wither of the two; And we will look for other's suggestion too. |
Yes I agree with you, that's exactly why I asked for suggestions! :) Once this PR is reviewed and merged, @Saumya-Mishra9129 would you like to port it to python3 and update sugargame version to 1.3? We can make a release after this maybe. :) |
Yeah Sure. |
|
Tested, thanks. Reviewed 8acaf49. @JuiP said
How did you determine it exactly? Also if the hard coded values can be avoided we should avoid them. @JuiP said
A global variable should be used because there's too many 45s and it's difficult to keep track of. 8acaf49 doesn't completely fix #17, the only part of #17 that's fixed is
Game also seems to freeze sometimes, nothing shows in the log Found a way to bypass levels easily by just creating a stick when I'm in front of one of the red patches on a pillar. Also can you explain your fix in a commit message and not just have |
@chimosky Can you please let me know the benefits of keeping it as a variable? I guess most of the width and height is already hardcoded and are not derived from any variable. I would prefer hardcoding them because it would reduce a lot of unwanted mess Before / now (int((57 + 45) * scale_x), int((39 + 45) * scale_y))), (birdxfast, 400 * scale_y))OR (int((57 + SHIFT_CORRECTOR) * scale_x), int((39 + SHIFT_CORRECTOR) * scale_y))), (birdxfast, 400 * scale_y))TO (after hardcoding) (int(102 * scale_x), int(84 * scale_y)), birdxfast, 400 * scale_y)
The freeze is because of #28
Wow; that's an important bug to fix. There is some chance that it might get fixed by merging #27. It was supposed to fix some loop errors. |
|
@srevinsaju said
The benefit being as they're hard coded, the values could also be changed again and having to change every 45 is definitely hectic and unnecessary. @srevinsaju said
If it was I should have been able to reproduce it but there was nothing in the logs. @srevinsaju said
I'm yet to test #27, I'll get to it soon. |
You can see the coordinates and widths of the black rectangles in this line I used them to determine the shift to center it.
Could you please have a look at this comment?
I agree with @srevinsaju. This is because of #28. Each time the game freezed, I got this traceback.
From looking at the code, @srevinsaju merging #27 will not fix this. This bug is due to the coordinates, will look at it!
Noted! |
welcomescreen.py
Outdated
|
|
||
| pygame.display.update() | ||
| clock.tick(60) | ||
|
|
||
| if crashed == True: # Game crash or Close check | ||
| if crashed == True: | ||
| # Game crash or Close check | ||
| pygame.quit() | ||
| sys.exit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest sys.exit() to be removed. Using sys.exit is not probably the right way to exit the loop. Use a return to terminate the loop gracefully. (I am not sure, if its applicable under this PR, but anyway, it would have to be removed before the last python2 release, I suppose)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing! :)
I don't agree. welcomescreen.py , rules.py and scorescreen.py return certain values. These values are used in if constructs and have a meaning. You can see here and here too. Using a return statement instead of sys.exit() might complicate how a contributor interprets code.
Also I'm not aware of the benefits of using return instead of sys.exit(). Could you please tell me why you suggested this, might help in some other activity :)
|
Thanks, tested d567207. On first run the game hung after I failed and this was shown in the logs; After restarting the game, on second run the game freezes and this is shown in the logs; I understand the second error might have been fixed in #27, I'll test it again as I wasn't able to get any errors when I tested earlier. |
|
Thanks for testing :)
I'm not sure what you are suggesting, did you get these errors only after I pushed the recent commits? I can reproduce the same errors on master. But they happen occassionally not on each test |
|
I've had a brief look. Review is made harder by flake8 changes. Are these needed within the pull request or can they be done later? |
|
Thanks. I've had another brief look. The new X and Y scaling feature for adapting to display size is good, but sloppy. You have a global constant defined in several files. You have a repeating pattern of using the constant and some other constants that aren't defined. It's the sort of situation where a new pair of functions (e.g. One or more of your commits fixes problems introduced in your earlier commits; you could squash those and not mention the problem. Some of your commit messages don't follow our guide to making commits. Hope that helps. |
I'll be more careful next time! :)
I'm not too sure how exactly do you want me to use the functions instead of the constants. I understand, that by explaining "how" you would be solving a part of the issue, I'm sorry I didnt quite understand how the functions can be implemented. |
I don't want to fall into the trap of being prescriptive, because then I'm the one doing the work instead of you, and all you become is a slave. I'm not a university lecturer. |
|
|
@quozl Implemented what you suggested and also squashed commits :) Please have a look now |
|
Do you like it better? I do. Further review;
Tested briefly. Still some actions by user are ignored, along with traceback of UnboundLocalError: local variable 'event' referenced before assignment, in line 706 of main.py. |
|
Thanks
Yes, I think it would be a good idea to put it in scale_img.
By misplaced, did you refer to the lines I marked in this comment?
I have described the problem in the short commit message below, but I do understand your point... I will add a one line summary instead :)
I think that's out of scope for this PR, @srevinsaju made another PR to fix this in #27
Could you please mention the actions that were ignored? My guess is it is to be fixed in #27 |
I don't understand. If you think his fix is worth having, why isn't it in your branch?
Keyboard actions. |
|
Yes, that's actually easier, I'll cherry-pick the commit but I'm slightly confused about your comment. We (@srevinsaju @JuiP @chimosky @Saumya-Mishra9129) tested the change, it worked. Do you think that it is the correct way to do it and I should add the commit here? |
|
You have the power. Use it wisely? I've not tested the change. I'm worried that by changing to handling one event per iteration the event loop is entirely different to what it was before, but if everyone is happy with it I guess it should be okay. I just haven't seen anyone say anything about it. |
|
I never got it to work in the past, so I am not sure of the mechanism it used previously. @quozl How better can it be reimplemented? Do you have anything in your mind which you would like to propose? I did not understand the difference in the current implementation, and that of which was (attempted) to be implemented in the past. But I can surely say the difference between #27 and #24
TL;DR > what was it before? I might have misunderstood the idea then. |
|
Yeah, it was always wrong. But it was a slightly better wrong. |
- Fixed the calculations of hard coded coordinates. ( + 45) helps to center it - The activity coordinates are hard coded for a system with display resolution as 1280*720. Scaling factor extends support to other screen dimensions. - Centre the activity canvas and support multiple resolutions. Fixes sugarlabs#19
- Pressing any key after game over cannot restart the game - This fixes : After clicking help button followed by Let's Play button, it takes you back to the scoreboard without playing a game - Reinitializing variables after Game Over ensures that it does not get into the if(fall == 1 or ext ==1) block - Fix sugarlabs#17
|
@quozl @chimosky @srevinsaju Have a look at the recent changes :) Maybe you could also update this comment Mostly finished work on this PR, could you please review and merge? |
|
Tested, reviewed. Activity works as expected, thanks. edited opening comment In relation to @quozl's statement here, in 3ae945 you added a "Fix #" and his comment was to point out that that shouldn't be included in the commit message as it's recognized by github but not git so it's not needed. I'll wait for @srevinsaju and @quozl who're involved to review. |
Ohh got it, won't include that next time at all @quozl asked me to add changes in #27 if I agree to it, so I added it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested until 16a7f63 . No errors in logs.
|
Closes #27 |
|
Tested, works as expected. Thanks. |
I'm working on the display resolution fix for the game, just finished fixing the welcomescreen, "how to play" and the scoreboard screen. I will make flake8 fixes in another commit.
@quozl used pygame instead of Gtk this time ;-)
Fixes #17.
@chimosky review changes till de21969 ?