www.main.lv
Don't think just code it

Search results for 'pygame'

2010-01-16 Math

Different stuff that have some math inside
2D Vector Library

Attractors

Attractor
Lorenz attractor

Fractals

Simple Fractal
Blender Fractal
Blender Towers

Numerical

Simposon integration method

Other

Voronoi
Pascal Triangle

2009-11-12 Python PyGame Tutorial Fullscreen

added new variable tha tcheck in with mode now screen is
fullscreen = False
Used new event type
if event.type == pygame.KEYDOWN:
When pressing key m we making new screen surface in fullscreen mode. If screen is in fuulscreen mode make window.
if event.key == pygame.K_m:		
  if not fullscreen:
    screen = pygame.display.set_mode( (SCREEN_X,SCREEN_Y) , pygame.FULLSCREEN )
    fullscreen = True
  else:
    screen = pygame.display.set_mode( (SCREEN_X,SCREEN_Y) )
    fullscreen = False
Tutorial Source

2009-09-23 Python Pygame Tutorial Randomnes

All boxes moving with same speed in same directions and all boxes have same size and colorMake changes step by step to see result

self.dx = randint(1,BOX_SPEED)
self.dy = randint(1,BOX_SPEED)
and boxes now moving all seperatly at diferent directions.
self.boxes.append( Box( i*2 , i*2 , randint(BOX_MIN_SIZE,BOX_MAX_SIZE) ,
(i,0,0) ) 
now boxes have diferent sizes
Tutorial source

2009-09-23 Python Pygame Tutorial Boxes Move

New class boxes handles many boxes. Number of boxes depends on cpnstant MAX_BOXES.

MAX_BOXES = 100
and all class Boxes methods is the same only diference is that it handles many boxes.Tutorial Source

2009-09-23 PyGame Lorenz attractor

Here is Lorenz attractor whery popular attractor i have used basic coloring tehnique.
Script
PovRay source

2009-09-15 Python Pygame Tutorial Box Move

added constants that helps controlling screen size

SCREEN_X = 500
SCREEN_Y = 500
BOX_SIZE = 20
BOX_SPEED = 1
box have speed by axis
self.dx = BOX_SPEED
self.dy = BOX_SPEE
detecting if given rect is inside screen borders or not if not then change it direction
def move( self ):
        if self.rect.left+BOX_SIZE > SCREEN_X:
            self.dx = -BOX_SPEED
        if self.rect.left < 0:
            self.dx = BOX_SPEED
        if self.rect.top+BOX_SIZE > SCREEN_Y:
            self.dy = -BOX_SPEED
        if self.rect.top < 0:
            self.dy = BOX_SPEED
        self.rect.left += self.dx
        self.rect.top += self.dy
after few line of code where added box move inside given screen and coalide with screen borders
Tutorial Source

2009-09-07 Python PyGame Tutorial Box Object

There is new object Box. We can draw, mask and move it.Once you init it you can use it with simple interface

box = Box( position_x , position_y , size ,
(color_red,color_green,color_blue,color_alpha) )
moving box to new position. new position calculates x_new = x_old + x
box.move( add_x , add_y )
drawes box on the screen
box.draw()
draw black box on the screen
box.mask()

Tutorial Source

2009-08-31 Python PyGame Tutorial Image Loading

Draw some image and make for it

surface image = pygame.image.load("image_name.format") 

then copy image surface to screen
surface. screen.blit( source_surface , (position_x,position_y) )

Tutorial source

2009-08-23 Python PyGame Tutorial Event System

Now you can set application window. But there is one problem you have to terminate application by killing.
Adding event handling help us exit from application by clicking close button or pressing some other button.

for event in pygame.event.get():
if event.type == pygame.QUIT:
    runing = False

Now you can exit from application by clicking close button.
Event types
There are defined other event types pygame.(KEYUP, KEYDOWN, MOUSEMOTION, MOUSEBUTTONP, MOUSEBUTTONDOWN, VIDEORESIZE). All of these events described in pygame documentation
Tutorial source

2009-08-23 Python PyGame Tutorial Display Setting

First application and we opening window

screen = pygame.display.set_mode( (width_of_window ,height_of_window ) )

In future we will use screen for drawing.
Also there possible make full screen with value pygame.FULLSCREEN
it looks like:
pygame.display.set_mode( (width,height), pygame.FULLSCREEN )


Tutorial Source

2009-08-23 Python PyGame Tutorial

Python Pygame tutorial. This tutorial goal show how to make small and simple pygame pythone script that include all that is need for bigger application. Every tutorial part add only few new lines of code.
Moving Boxes
Goal
Make featured applications with boxes that coaliding one with another.
1. [Set Display]
2. [Event Sytem]
3. [Image loading]
4. [Box object]
5. [Box move]
6. [Boxes move]
7. [Randomnes]
8. [Fullscreen]

2009-06-02 Voronoi distance

I where interested to see how looks visualy distance to the closest point. When I saw result i remembered that it is Voronoi diagramm.
Download

2009-05-07 PyGame Attractors

I have found old article about attractors that is resoult what I have done with playing with attractor values. Attractor formula is very simple but result is interesting.

2009-04-15 PyGame Rotating Flower

Flower where all list rotating around lists.
SDownload

2009-04-13 Map Editor

This is simple map editor for small games. Also I think it will be useful for other people who started writing game and made first test maps.
Download

2009-03-18 PyGame Post

Wanted to know how will looks when mousepointer moving and all arrows shows it direction
Download

2009-02-14 PyGame Bullets with Boxes

You can shut your bullets and they will contact with difrent boxes with diffrent result there is boxes that speed up, freeze, slow down bullets.
Download

2009-02-12 Pygame Border Coalision

I wanted to know how many simple object can be drawn by Pygame. Red point is starting point for flying bullets. And only thing with bullets have coalision is screen border. You can shut new bullets with mouse.
Download Script
After some optimisations script works faster.
Download Script v2
Also I have implemented the same on C++.
Download Source

2008-09-14 Star generator

Python scripth with generating picture of points from bmp image. Colors in bmp image is like koeficent map with allow generate more random points in any place of image you want. There shown source image from what where generated points on black image.
Download

2008-09-07 Simple Fractals

Here is some Fractal examples. That is my first fractals.
Start Script
Circle Script