This site requires JavaScript, please enable it in your browser!
Greenfoot back
newgfteacher
newgfteacher wrote ...

2022/2/17

Actors (graphics) only show up when the game gets to the end, instead of during

newgfteacher newgfteacher

2022/2/17

#
I am learning Greenfoot to teach it to my students and I thought it would be fun practice to try to code Wordle. My program is working as expected except that the graphics (Actors that are essentially coloured tiles, and an Actor that prints a word through setImage) only show up AFTER the game has been won or lost. While the game is in progress, the graphics space is blurred out. The graphics should be showing up after each guess has been entered by the user (using Greenfoot.ask). For testing purposes, if I set something to System.out.print in the terminal window in the same places in the code where I use addObject for my Actors, that prints in the terminal window after each inputted guess, as it should. Why don't the graphics/Actors behave similarly? I have only done one other (incomplete) program in Greenfoot prior to this and it was a running game just with an Actor controlled by the arrow keys, so I'm wondering if there is something I am not understanding about how Greenfoot works. Thanks in advance!
RcCookie RcCookie

2022/2/17

#
You can use getWorld().repaint() to force repaining, or only make one input request per act cycle. Greenfoot only renders the world after the frame, so no blocking actions should be used.
newgfteacher newgfteacher

2022/2/18

#
RcCookie wrote...
You can use getWorld().repaint() to force repaining, or only make one input request per act cycle. Greenfoot only renders the world after the frame, so no blocking actions should be used.
Thank you, I will give those options a try soon and report back!
danpost danpost

2022/2/20

#
newgfteacher wrote...
The graphics should be showing up after each guess has been entered by the user (using Greenfoot.ask).
If I were to do a Wordle game (which I have a non-uploaded test scenario using 2 different words and no dictionary to check word entries), I would not use the Greenfoot.ask method. I would have the tiles show the entered letters as they are being entered (which is what I did).
newgfteacher newgfteacher

2022/3/18

#
RcCookie wrote...
You can use getWorld().repaint() to force repaining, or only make one input request per act cycle. Greenfoot only renders the world after the frame, so no blocking actions should be used.
Finally got my head around the act thing and it is working! Thank you!!
danpost wrote...
newgfteacher wrote...
The graphics should be showing up after each guess has been entered by the user (using Greenfoot.ask).
If I were to do a Wordle game (which I have a non-uploaded test scenario using 2 different words and no dictionary to check word entries), I would not use the Greenfoot.ask method. I would have the tiles show the entered letters as they are being entered (which is what I did).
I think I'll take your suggestion! Greenfoot.ask has been behaving weirdly so right now I have them entered in the terminal window.
You need to login to post a reply.