exploring a primitive physics engine in emulated Python
What other Python emulators offer some builtin physics? Example startup code (no imports required): stage.set_gravity(3) escaped = False stage.disable_ceiling() stage.set_background_color("black") b = 1 stage.set_bounce(b) Codesters embraces turtle graphics but takes it to the next level by providing: (a) gravity (numeric) (b) sprite-level physics (on or off) (c) bounciness (numeric) (d) whether walls are bouncy (enable / disable) (e) collision detection (callback function) Adding these features requires an event loop type architecture, which Codesters keeps cleverly hidden i.e. there's no low level asyncio work required by students. We do have callback we can fire at set intervals (a user setting). I make full use of this interval in the first two videos (link below), as I experiment with some of the parameters mentioned above. Example 1: Escape Velocity def interval(): global escaped pos = sprite.get_y() if pos > 100 and not escaped: escaped = True sprite.set_gravity_off() sprite.say("Escape velocity achieved") sprite.set_x_speed(0.2 * sprite.get_x_speed()) sprite.set_y_speed(0.2 * sprite.get_y_speed()) Example 2: Bounce World def interval(): global b stage.set_bounce(b) b = b - 0.3 Changing bounciness has some perhaps unexpected effects when it goes negative. Absolute value is what matters. The last video (3 of 3) goes back to the Powerpoint / slideshow potential that develops once importing png, gif, jpg "sprites" over the internet is in the picture. Codesters supports that. MIT Scratch offers this capability as well. The ability to import graphics is popular with kids, however usually not at first in the context of making slideshows. Most of them have yet to be put on the spot to do Powerpoint or any of those. However developing one's show and tell presentation skills is a big part of learning I'd say. Extending the Show & Tell protocol to include slide sharing is what Ignite is/was all about, right? Do people still stage Ignite events? Those were cool! What I need to do more of in Codesters: explore sound effects. I wrote all the parents in my class after OSCON that Codesters didn't have sound. Then, duh, I found it. During demo day I encouraged looking in to that feature. This was at Carl Sandburg College in Illinois, me connecting remotely from two time zones away, from Portland. None of the videos curated here were actually used during that summer camp (I didn't show any Youtubes, either by me or anyone else, during the actual 2.25 hour meetups -- but I did recommend some for followup [1]). These give the flavor of the kind of thing we were doing: http://mybizmo.blogspot.com/2019/07/computing-surface-workouts.html My apologies for missing the Python booth at OSCON this year. I saw the stuffed snake, more sensibly sized than mega-sized Naga, our mascot emeritus. https://flic.kr/p/26wac5J (Naga, I still have her, and should eventually donate her to the Python Language exhibit -- might be some rooms in a bigger Languages Museum right?). Kirby [1] for middle school aged kids I often recommend Python tutorials by Socratica on Youtube. Also 'Warriors of the Net' an ancient classic about packet switching (the TCP/IP layer). https://youtu.be/PBWhzz_Gn10 I also showed Math Adventures with Python by Peter Farrell which typifies the need any math student will have for a bigger screen. Peter's book includes rotation matrices applied against polyhedrons, as my curriculum does. No sense tackling matrix math on a scientific calculator right? Even if it's possible.
participants (1)
-
kirby urner