hp
jblog
toc

JClock IV

2015-08-08, post № 53

programming, Pygame, Python, #alternative, #arc, #around the center, #background, #clock, #clockface, #displaying time, #draw, #rgb, #rgb clock, #rgbw, #spawn time, #time, #time display, #time reading

Combining the built-in Pygame function pygame.draw.arc() with time, I came up with this alternative clock design.
The red arc represents hours, the green one minutes, the blue seconds and the white arc represents centiseconds (a hundredth of a second).
Although it is a clock, you read it anti-clockwise.

jclock-iv-2.png
Source code: jclock-iv.py
Extra assets: jclock-iv-1.png

Pattern

2015-08-02, post № 52

programming, Pygame, Python, #art, #backgroud, #color, #colors, #diamond, #entities, #entity, #gradient, #move, #movement, #moving, #pipes, #wallpaper

Using colors and entities, this program can generate some nice-looking pictures. The entities move randomly across the screen, always staying in a grid layout. Their color is defined by an increasing tick variable, which gives them a nice gradient.

Controls

  • ‘Space’ spawns in new entities,
  • ‘m’ pauses and resumes the movement of entities.
pattern-1.png
pattern-2.png
pattern-4.png
Source code: pattern.py

Jeakout

2015-08-01, post № 51

games, programming, Pygame, Python, #arcade, #arcade game, #Atari, #break, #break blocks, #breaking, #breaking blocks, #com, #computer play, #game, #games

Continuing with my arcade game replicas, I programmed Breakout.
This version is fairly simple. Your lives will be displayed at the lower right corner, your points in the screen’s caption. There also is a computer implementation, which — as in Jong — cannot lose.

Usage

  • Left arrow key moves the hitter to the left,
  • Right arrow key moves the hitter to the right,
  • ‘Space’ toggles computer play.
jeakout-1.png
jeakout-2.png
jeakout-3.png
Source code: jeakout.py

Bobble Throw

2015-07-26, post № 50

programming, Pygame, Python, #active, #art, #background, #black, #blue, #bobble, #bobbles, #bounce off, #colors, #mouse, #mouse control, #movement, #moving

Playing around with circles and colors, I came up with this good-looking program. If active, 𝟨𝟢 bobbles per second will spawn at your cursor position. They will bounce off the four edges of your screen, start fading towards black and eventually go away completely.

Controls

  • ‘Space’ toggles whether or not the bobbles are moving.
bobble-throw-2.png
bobble-throw-3.png
bobble-throw-1.png
Source code: bobble-throw.py

Menger Sponge

2015-07-25, post № 49

programming, Pygame, Python, #black, #blue, #divide, #endless, #fractal, #infinite, #sponge

Normally, the Menger Sponge is a three-dimensional cuboid. This program works in a two-dimensional space, so it only shows one side of the sponge.
Because a computer has its capacities, I capped the maximum square count to 𝟣𝟢𝟢𝟢𝟢. After that maximum, the face will not be complete.

Controls

  • ‘Space’ divides every square once again.
menger-sponge-1.png
menger-sponge-2.png
menger-sponge-3.png
menger-sponge-4.png
menger-sponge-5.png
Source code: menger-sponge.py

Prime Spiral II

2015-07-19, post № 48

programming, Pygame, Python, #around the center, #black, #black and white, #circle, #curcular, #generates, #generator, #getCirclePos(), #gray, #prime, #primes, #spinning, #spiral

My first attempt at making a prime spiral worked, but it worked with 𝟫𝟢° angles. Trying to make it look smoother, I now used an angle and a distance, drawing circles at calculated position.
If the number is prime, it gets white. If it is not, the circle will be gray.

prime-spiral-ii.png
Source code: prime-spiral-ii.py

Sierpiński triangle

2015-07-18, post № 47

mathematics, programming, Pygame, Python, #3, #3-gon, #around the center, #black, #black and white, #fractal, #generates, #generating, #generator, #three, #triangle, #white

Having recently heard something about chaos theory, I was interested in the Sierpiński triangle. Specifically in the random generation. To prove that it can really be generated using a die, I wrote this program.

How it works

  • You start with any point inside the triangle (I chose the center).
  • A triangle has three points, let us call them 𝐴, 𝐵 and 𝐶.
  • You choose randomly between one of those three points, go half the distance and set a pixel right there.
  • Repeating this process over and over again (always starting at your last point), you eventually [1] get the Sierpiński triangle.

Controls

  • ‘Space’ toggles if the triangle is generated,
  • ‘m’ toggles if the current position is shown (indicated by a blue circle).
sierpinski-triangle-1.png
sierpinski-triangle-2.png
sierpinski-triangle-4.png
Source code: sierpinski-triangle.py

Jic-Jac-Joe

2015-07-12, post № 46

games, programming, Pygame, Python, #AI, #algorithm, #blue, #com, #computer, #pixel, #pixel graphics, #tac, #tic, #tic-tac-toe, #tictactoe, #toe, #TTT

As the name suggests, this is a computer version of the well-known game Tic-Tac-Toe. This version supports a computer player, but it is not the smartest algorithm and can lose. In this setup, the computer plays ‘O’ and starts, the player plays ‘X’.
Win detection is fully implemented.

Controls

  • The 𝟥 ⨉ 𝟥-field is projected on the numpad, so 7 sets your piece in the upper left corner and 3 puts it in the lower right corner.
  • Escape resets the game.
jic-jac-joe-1.png
jic-jac-joe-2.png
jic-jac-joe-3.png
Source code: jic-jac-joe.py
Jonathan Frech's blog; built 2022/01/16 06:13:11 CET