www.main.lv

Don't think just code it

Menu

  • Projects
    • Robatik
    • ArpSni
  • Samples
    • FreeBSD Asm
    • Linux Asm
    • PyGame Tutorial
    • UNIX programming
    • PSP programming
    • AVR
    • Math
  • Contact

Tags

algo (1)asm (19)attractor (2)avr (2)blender (3)bug (1)c (25)coalision (2)debug (3)editor (1)elf (1)fractals (2)freebsd (3)game (3)generator (1)gimp (1)int80h (22)map (1)math (5)mit (1)nano (1)net (2)opengl (1)plugin (1)post (2)povray (1)psp (3)pygame (19)python (28)robatik (2)sdl (3)skype (2)sql (1)towers (2)tutorial (7)voronoi (1)wudu (1)

Archive

  • 2010 august (1)
  • 2010 july (2)
  • 2010 june (1)
  • 2010 april (2)
  • 2010 march (2)
  • 2010 february (2)
  • 2010 january (2)
  • 2009 december (3)
  • 2009 november (8)
  • 2009 october (3)
  • 2009 september (5)
  • 2009 august (1)
  • 2009 july (1)
  • 2009 june (1)
  • 2009 may (1)
  • 2009 april (3)
  • 2009 march (1)
  • 2009 february (2)
  • 2009 january (1)
  • 2008 october (2)
  • 2008 september (4)

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


2009-10-30 Linux assembler SDL

Open SDL window from asm. I tryed to open SDL window from asm. And that worked. Hardest thing is defining all structures from SDL headers. Windows opening and waiting while anykey will pressed.

include 'cdecl.inc'
 
format ELF
 
extrn SDL_Init
extrn SDL_SetVideoMode
extrn SDL_PollEvent
extrn SDL_Quit
 
;video settings
SDL_INIT_VIDEO	equ 0x00000020
SDL_FULLSCREEN	equ 0x80000000
 
;event settings
SDL_KEYDOWN         equ 2
SDL_MOUSEBUTTONDOWN equ 5
 
;programm settings
SCREEN_WIDTH equ 800
SCREEN_HEIGHT equ 600
SCREEN_BPP equ 24
 
struc SDL_keysym
{
	.scancode 	db 0
	.sym 		dd 0
	.mod		dd 0
	.unicode 	dd 0
}
 
struc SDL_KeyboardEvent
{
	.type  db 0
	.which db 0
	.state db 0
	.keysym SDL_keysym
}
 
struc SDL_Event
{
	.type db 0
	union SDL_KeyboardEvent
	.empty db 0,0,0
}
 
 
section '.text' executable
public _start
_start:
	ccall SDL_Init,SDL_INIT_VIDEO
	ccall SDL_SetVideoMode, SCREEN_WIDTH , SCREEN_HEIGHT , SCREEN_BPP , SDL_FULLSCREEN
	;try to make while loop
while_run:	
	while_polleEvent:
		ccall SDL_PollEvent, event
		cmp eax, 0
		je	while_polleEventquit
		cmp byte [event.type], SDL_KEYDOWN
		jne	while_polleEvent
		mov byte [run], 0
		jmp while_polleEvent
	while_polleEventquit:
 
	; if run != 1 quit
	cmp byte [run], 1	
	je	while_run
 
	ccall SDL_Quit, 0
 
	mov eax, 1
	xor ebx, ebx
	int 80h
 
section '.data' writeable
event		SDL_Event
run 		db 		1


Compile with lines:

fasm sdl.asm sdl.o

ld -dynamic-linker /lib/ld-linux.so.2 sdl.o /usr/lib/libSDL.so -o sdl

Dowload Source



2009-11-15 Pascal Triangle

This is Pascal Triangle. And colors is choseen by reminder of division.
There are 2 ways how thats is made:
1. Simple if division reminder is 0 then red else green
2. Reminder is like alpha chanell of red color.
In gallery shown images are generated by dividing on (17,19,23,41,42,43). There is easy to see that
prime numbers (17,19,41,43) has very structured triangle but not prime (42) is different.
./chessboard div_number - simply show triangle divided by number
./chessboard div image.tga - save programm screen to image.tga
./chessboard div img.tga ant_parm - changes to second coloring type
Why it I call it chessboard? I were trying make such with OpenGL bet result is Pascal Triangle.


Source


© 2010