Turmites creator

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Turmites creator

Post by Psychophanta »

An simple program found at https://es.wikipedia.org/wiki/DIV_Games_Studio in the old DIV-Games code and translated to PB code.
I added the Beep_() commands in the source.
Modify and upgrade it at your taste. :)

Code: Select all

;Program TURMITE
; https://en.wikipedia.org/wiki/Turmite

; A PB conversion of example program found at: https://es.wikipedia.org/wiki/DIV_Games_Studio
; September 2016, Psychophanta

Global orientacion=1,xa=160,ya=120,velocidad=10,a=1

InitSprite():InitKeyboard()
OpenWindowedScreen(OpenWindow(0,0,0,xa*2,ya*2,"Turmites",#PB_Window_SystemMenu|#PB_Window_ScreenCentered),0,0,xa*2,ya*2,1,0,0,#PB_Screen_NoSynchronization)

Procedure derecha()
  orientacion+1
  If orientacion>4:orientacion=1:EndIf
  Select orientacion
    Case 1:xa-a
    Case 2:ya+a
    Case 3:xa+a
    Case 4:ya-a
  EndSelect
EndProcedure

Procedure izquierda()
  orientacion-1
  If orientacion<1:orientacion=4:EndIf
  Select orientacion
    Case 1:xa+a
    Case 2:ya-a
    Case 3:xa-a
    Case 4:ya+a
  EndSelect
EndProcedure

Repeat
  ExamineKeyboard()
  If xa<0:xa=320:EndIf
  If xa>320:xa=0:EndIf
  If ya<0:ya=240:EndIf
  If ya>240:ya=0:EndIf
  If KeyboardPushed(#PB_Key_A):velocidad-1:If velocidad<1:velocidad=1:EndIf:EndIf
  If KeyboardPushed(#PB_Key_D):velocidad+1:EndIf
  StartDrawing(ScreenOutput())
  DrawText(0,0,"Pulsa A para aumentar la velocidad")
  DrawText(0,20,"Pulsa D para disminuir la velocidad")
  Select Point(xa,ya)
    Case 0:Beep_(200,10):Plot(xa,ya,$2222aa):derecha()
    Case $2222aa:Beep_(400,10):Plot(xa,ya,$22aa22):derecha()
    Case $22aa22:Beep_(600,10):Plot(xa,ya,$aa2222):izquierda():izquierda()
    Case $aa2222:Beep_(800,10):Plot(xa,ya,0):izquierda():izquierda()
  EndSelect
  StopDrawing()
  Delay(velocidad)
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Turmites creator

Post by Kwai chang caine »

It's a very "small" game for my bad old eyes :shock:
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Turmites creator

Post by Keya »

yes i recommend changing each plot from 1 to 4 pixels :D very interesting little game as described in your wiki link, i know of Conway's Game of Life but had never heard of these Turmites before... quite a different animal :)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Turmites creator

Post by Psychophanta »

You are welcome Kwai Chang.
Yes Keya, I also never heard about "Turmites" before, that's why it took my attention and I translated this little example to PB.
I did a search in PB forum about "Turmite", but nothing, so I am proud to be the first one introducing Turmites in PB forum. :wink:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply