PurePunch Contest #2
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Out of competition (it would not qualify anyway
) the next version of PPV to accomodate for the rules change 


Code: Select all
; PPV v0.02 blueznl
;
; PurePunch Validator
;
title.s = "PurePunch Validator v0.03 by BluezNL"
;
category_1 = #True ; set to false if it's more than 10 lines or a line has more than 256 chars
category_2 = #True ; set to false if it's more than 100 lines or a line contains multiple statements
category_3 = #True ; set to false if the total number of chars is more than 2560
category_4 = #True ; set to false if it's more than 10 lines or a line has more than 80 chars
;
; note: all lines are trimmed, and empty lines and comment only lines are ignored
;
line_nr = 0
line_qualifying_nr = 0
line_l_max = 0
line_l_max_nr = 0
char_nr = 0
;
; f.s = ProgramParameter()
; f.s = "d:\purebasic\_projects\test.pb"
; f.s = "d:\purebasic\_projects\x_lib\x_lib.pb"
; f.s = "d:\purebasic\_projects\ppv.pb"
; f.s = "d:\purebasic\_projects\test.pb"
;
If f.s = ""
f = OpenFileRequester(title,"","PureBasic|*.pb|All files|*.*",0)
EndIf
If FileSize(f) > 1
ReadFile(1,f)
While (category_1 Or category_2 Or category_3) And (Not Eof(1))
y.s = Trim(ReadString(1,#PB_UTF8))
line_nr = line_nr+1
If y = ""
ElseIf Left(y,1)=";"
Else
line_qualifying_nr = line_qualifying_nr+1
line_l = Len(y)
If line_l > line_max
line_l_max = line_l
line_l_max_nr = line_nr
EndIf
;
; category no.1: 256 characters or less
;
If line_l > 256
category_1 = #False
EndIf
;
; category no. 1: not too many lines? 10 or less
;
If line_qualifying_nr > 10
category_1 = #False
EndIf
;
; category no.2: not too many lines? 100 or less
;
If line_qualifying_nr > 100
category_2 = false
EndIf
;
; category no.2: single statement test
;
p_n = CountString(y,#DQUOTE$)
If p_n > 0
x.s = ""
p = 1
While p <= p_n+1
x = x+StringField(y,p,#DQUOTE$)
p = p+2
Wend
y = x
EndIf
p_n = CountString(y,"'")
If p_n > 0
x = ""
p = 1
While p <= p_n+1
x = x+StringField(y,p,"'")
p = p+2
Wend
y = x
EndIf
p_n = CountString(y,";")
If p_n > 0
x = ""
p = 1
While p <= p_n+1
x = x+StringField(y,p,";")
p = p+2
Wend
y = x
EndIf
If CountString(y,":") > 0
category_2 = #False
EndIf
;
; category no.3: Not too large?
;
char_nr = char_nr + line_l
If char_nr > 2560
category_3 = false
EndIf
;
; category no.4: max. 10 lines of max. 80 characters
;
If line_l > 80 Or line_qualifying_nr > 10
category_4 = #False
EndIf
;
EndIf
Wend
CloseFile(1)
;
y = "Lines: "+Str(line_nr)+Chr(13)
y = y+"Qualifying lines: "+Str(line_qualifying_nr)+Chr(13)
y = y+"Longest line: "+Str(line_l_max_nr)+" ("+Str(line_l_max)+" characters)"+Chr(13)
y = y+"Length: "+Str(char_nr)+" characters"
;
x = ""
If category_1
x = x+Chr(13)+"CATEGORY I - PASSED - max 10 lines of max 256 characters"
Else
x = x+Chr(13)+"CATEGORY I - FAILED"
EndIf
If category_2
x = x+Chr(13)+"CATEGORY II - PASSED - max 100 qualifying lines with each one statement"
Else
x = x+Chr(13)+"CATEGORY II - FAILED"
EndIf
If category_3
x = x+Chr(13)+"CATEGORY III - PASSED - max 2560 characters"
EndIf
x = x+Chr(13)
If category_4
x = x+Chr(13)+"JUNE 2009 - PASSED - max 10 qualifying lines of max 80 characters"
Else
x = x+Chr(13)+"JUNE 2009 - FAILED"
EndIf
MessageRequester(title,f+Chr(13)+Chr(13)+y+Chr(13)+x,#PB_MessageRequester_Ok)
;
EndIf
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
after raytracing , raycasting 
it's very hard to respect the rules!

it's very hard to respect the rules!

Code: Select all
;*****************************************************************************
;*
;* Name : RayCasting 640x480
;* Author : Cpl.Bator
;* Date : 3/06/2009
;* Notes : Tested on linux , program quit automatically
;*
;*****************************************************************************
w=1024:x=360:px=9*w:py=11*w:st=5:he=0:tr=1:Fc=$FFFFFF:Macro rnd(v):Random(v);##
EndMacro:Macro ef:EndIf:EndMacro:Dim L(20,20):For c=0 To 11:L(C,12)=rnd(Fc);###
b=540:L(C,0)=rnd(Fc):L(12,C)=rnd(Fc):L(0,C)=rnd(Fc):L(rnd(11),rnd(11))=rnd(Fc);
Next:Dim t(b):For i=0 To b:t(i) = (Cos((i*0.0174))*w)/10:Next:InitSprite():u=91
OpenScreen(640,480,32,""):Repeat:x1=0:y1=0:x2=0:y2=0:tm+1:q=100:If t<tm:t=tm+10
he=(he+tr)%x:ef:StartDrawing(ScreenOutput()):gl=he-44%x:If gl<0:gl=gl+x:ef;####
For a=gl To gl+89:xx=px:yy=py:tx=t(a+u):ty=t(a+1):l=0:While 1:xx=xx-tx:yy=yy-ty
l=l+1:O=(xx/w)%12:Li=(yy/w)%12:If L(Li,O)!0:Break:ef:Wend:h=900/l:y1=q-h:y2=q+h
x2=x1+3:Box(x1*2,y1*2,12,h*6,L(Li,O)):x1 = x2+1:Next:StopDrawing();############
FlipBuffers(2):ClearScreen(0):Until tm>10000;##################################
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
There were no other limitations, so feel free to write your code for your specific platform, I guess. And yeah, it it's your local ZX Spectrum port of PureBasic, it will be hard to show to the rest of us how great your code is... but don't worry, voting will fix all that, and there's nothing wrong with you that a little re-incarnation cannot cure 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Because InitKeyboard() , ExamineKeyboard() , keyboardpushed()... is too big , my program's quit automatically , stop.djes wrote:Why?Cpl.Bator wrote:with the rules , i can't use keyboard command :roll:Notes : Tested on linux , program quit automatically
if you are not happy , don't test the program.
bye.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
well, let me say, you should better post two versions, if you want the others to vote for the code.Cpl.Bator wrote:We don't live on the same planet...but you need to post TWO versions with different
because, if keyboardpushed() is too big for you, what about #PB_Key_Escape...?
but you can just replace it with 1 on windows, dunno what the Linux Value is.
... but if it wasn't for the length of the constants, and you are not on linux,
I just misinterpreted the reason why you said "can't use keyboard"...
oh... and have a nice day.