Glen Chiacchieri

@glench (42)
How to use Svelte in Repl ??
posted to Ask by karanganesan

I'd love to have Svelte in Repl.it!

Physics Fun with Python Play
posted to Share by timmy_i_chen

@PaoloAmoroso Python Play does use the asyncio features of Python 3. async/await were added in Python 3.5 (source) so you just need a version of Python greater than that (which repl.it has). If you want to use Python Play on repl.it, you just need to use a Python (3) repl and install replit-play in the package manager. Or you can just fork this repl.

And the reason for using async/await is mostly to be able to set up timers. In normal loop-based python programming, it's really annoying (especially for beginners) to make a program that changes the background to red, waits 1 second, changes to green, waits 1 second, then changes to blue and cycles back to red. In Python Play you can just do that like this:

@play.repeat_forever
async def do():
  play.set_backdrop('red')
  await play.timer(seconds=1)
  play.set_backdrop('green')
  await play.timer(seconds=1)
  play.set_backdrop('blue')
  await play.timer(seconds=1)

link to repl with above code

Improved DVD logo
posted to Share by Russell23

This is great! I modified it a little bit so it looks smoother, especially on the first bounce: https://repl.it/@glench/dvd-colour-swap-1

👾🎉 Announcing Python Play (beta) & a pong game tutorial
posted to Tutorials by glench

@PeymanTalkhekar thanks for the report! I just fixed the issue. Give it a few minutes and try again (make sure you have replit-play version 0.0.17 or higher).

PySimpleGUI Adds Support For Repl.it
posted to Announcements by amasad

@DavideRosa Yeah, but it doesn't work in the repl.it IDE/editor, which is the bug I'm reporting.

👾🎉 Announcing Python Play (beta) & a pong game tutorial
posted to Tutorials by glench

@Fredrichcoder It should be pygame, but you can just fork the repl to make a copy that has everything set up correctly and then just change the code.

👾🎉 Announcing Python Play (beta) & a pong game tutorial
posted to Tutorials by glench

@yoonji1010 hey! The repl you shared with me works just fine. After you hit run, try clicking your mouse in the area of the game first and THEN pressing up or down. Sometimes the keyboard focus is still in the text editor after you hit run.

Help with my 'Pong' game
posted to Ask by vitorcurado

@FootSpecialist ok. I’ll just say that being nice and affirming as opposed to sarcastic and unaffirming is a vastly underrated way to be. And check the response to your comment from the person it was aimed at: wouldn’t it be better if your comments didn’t cause people to frown?

Help with my 'Pong' game
posted to Ask by vitorcurado

You can also read more about the different commands in Python Play (including adding images) here: https://github.com/replit/play

Help with my 'Pong' game
posted to Ask by vitorcurado

@FootSpecialist hey! I think you might have been joking around with @PYer which is cool, but in text it's a little hard to tell if you're joking or being mean. It's okay if someone that likes Python doesn't know much about pygame. I've been coding for over 10 years and I didn't know anything about pygame until a few months ago! So if you were joking please let us know and if you weren't, please try to be nicer since we're all learning here :)

Help with my 'Pong' game
posted to Ask by vitorcurado

Hey @vitorcurado, looks like you're using Play and the pong tutorial I wrote! Cool! I'd love to offer some help here. In programming, it's helpful to break down what you want.

First, we need the text you want to display, something like "You lost :(". To do that, you can add this line of code near the beginning of your program:

losing_text = play.new_text('You lost :(', font_size=120)

Try it out and see if the text shows up. If the text is showing up, it will stay on the screen even when you start the game, which isn't what we want. So for now we should hide the text with the hide command:

losing_text = play.new_text('You lost :(', font_size=120)
losing_text.hide()

We'll bring it back when we detect the player loses.

Second, you want to know when the player loses. How do you detect when the player loses? In most pong games, the player loses when the ball goes past the player's paddle or past the edge of the screen. How do we translate this into code?

To check for a condition, Python's if statement is what you want. You can do something like this:

# check to see if the ball has gone past the right of the screen
@play.repeat_forever
async def check_losing():
    if ball.x > play.screen.right:
        losing_text.show()

This will repeatedly check if the ball's x position (its horizontal position) is bigger than (>) the position of right of the screen. If it is, we'll show the losing text we made earlier. Try it out, does it work?

Once it's working, the third thing you said you want to do is wait three seconds. In Python Play, there's a special command to wait called the timer. You use it like this:

# check to see if the ball has gone past the right of the screen
@play.repeat_forever
async def check_losing():
  if ball.x > play.screen.right:
    losing_text.show()

    await play.timer(seconds=3)

But what do we want to have happen after three seconds? We want to hide the losing text and put the ball back in the middle of the screen. You can do that with two more commands, like this:

# check if the ball has passed the right of the screen
@play.repeat_forever
async def check_losing():
  if ball.x > play.screen.right:
    losing_text.show()

    await play.timer(seconds=3)

    losing_text.hide()
    ball.go_to(x=0, y=0) # go back to the center of the screen

And that's it! I think this should do what you want. Check this repl I made for you with the new code. I hope this helps!

Improved DVD logo
posted to Share by Russell23

Hey I tried remaking this project with the Python Play library that we just released on repl.it. Here it is: https://repl.it/@glench/DVD-Logo-screensaver-remake

It also chooses a random color to change to once it bounces off an edge.

PySimpleGUI Adds Support For Repl.it
posted to Announcements by amasad

@DavideRosa I mean, I wanted to use the __repl to see and modify the source. Even when I forked it it didn't work :(

PySimpleGUI Adds Support For Repl.it
posted to Announcements by amasad

@DavideRosa Works fine in Safari and Chrome (although video won't play probably due to 3rd-party cookies being disabled).

However, when I go to http://remiexample--daviderosa.repl.co/__repl it works in Safari but then fails when I tried to fork it. In Chrome when I go to the __repl url it fails both viewing your project and forking my own version.

PySimpleGUI Adds Support For Repl.it
posted to Announcements by amasad

@DavideRosa oh huh! I have the most recent Chrome (beta) and Safari and my internet is fast. In Chrome I have 3rd party cookies disabled and in Safari I have what looks like default setting of cookies enabled from websites I visit.

PySimpleGUI Adds Support For Repl.it
posted to Announcements by amasad

@amasad Same thing seems to happen even after I fork it. In Chrome it reloads slowly, and in Safari it just keeps reloading continuously:

PySimpleGUI Adds Support For Repl.it
posted to Announcements by amasad

@amasad When I try to use this repl I keep getting what looks like a loading screen whenever I do something. Can't actually try the app:

3 line calculator
posted to Share by SwaagatB

@SwaagatB I wonder if you could add some error checking. Once you type something like 1 / 0 it breaks the calculator. Maybe you could make it say something like "hey, that's not valid math!"