Code archives/Graphics/Grid

This code has been declared by its author to be Public Domain code.

Download source code

Grid by jankupila2010
Grid
Strict

Graphics 1024,768

Type cells
	Field x
	Field y
	Method piirra()
		SetColor 255,2552,255
		DrawLine x,y,x,y+20
		DrawLine x,y,x+20,y
		SetColor 80,80,80
		DrawLine x+20,y,x+20,y+20
		DrawLine x,y+20,x+20,y+20
		DrawRect x+1,y+1,18,18
	End Method
End Type



Local cell:cells=New cells

For Local t=100 To 924 Step 22
	For Local i=100 To 668 Step 22
		cell.x=t
		cell.y=i
		cell.piirra()
	Next
Next

Flip

WaitKey

Comments

_Skully2010
Posts like this do nothing but clutter the code archives with junk.


jankupila2010
What's wrong with that? I will do it better if you say how.


TaskMaster2010
Yep. There is even a bug...


TaskMaster2010
What he means by "clutter the code archives" is that this piece of code is way too basic to be here.

The code archives is for useful code. This should be posted in the beginners section, if anywhere.


jankupila2010
Ok thanks. By the way, I didnt find the bug.


Jesse2010
I like it I. I think it's creative. I do think it could be useful for somebody even as simple as it is. a beginner might find it usefull.

One thing I disagree is with the code formatting. I think code submitted to the code archives should have mandatory indentation and the code should be in 'Strict' mode.


jankupila2010
I edited the code.
I made intendations and I changed it to 'strict' mode.


_Skully2010
Strict
Graphics 1024,768
For Local x=100 To 924 Step 22
	For Local y=100 To 668 Step 22
		SetColor 255,252,255
		DrawLine x,y,x,y+20
		DrawLine x,y,x+20,y
		SetColor 80,80,80
		DrawLine x+20,y,x+20,y+20
		DrawLine x,y+20,x+20,y+20
		DrawRect x+1,y+1,18,18
	Next
Next
Flip
WaitKey



puki2010
Personally, I prefer the Blitz3D version:

Graphics 1024,768,0,2
For x=100 To 924 Step 22
    For y=100 To 668 Step 22
        Color 255,255,255
        Line x,y,x,y+20
        Line x,y,x+20,y
        Color 80,80,80
        Line x+20,y,x+20,y+20
        Line x,y+20,x+20,y+20
        Rect x+1,y+1,18,18,0
    Next
Next
Flip
WaitKey()End


It's less strict.

Edited out "_Skully's" '2552' error.


puki2010
This is a bit more exciting:
SeedRnd MilliSecs()
Graphics 1024,768,0,2
For x=100 To 924 Step 22
    For y=100 To 668 Step 22
        Color Rand(1,255),Rand(1,255),Rand(1,255)
        Line x,y,x,y+20
        Line x,y,x+20,y
        Color Rand(1,255),Rand(1,255),Rand(1,255)
        Line x+20,y,x+20,y+20
        Line x,y+20,x+20,y+20
        Rect x+1,y+1,18,18,1
    Next
Next
Flip
WaitKey()
End

Blitz3D only.

Looks a bit like mosaic flooring.


Or even:
SeedRnd MilliSecs()
Graphics 1024,768,0,2
Repeat
For x=100 To 924 Step 22
    For y=100 To 668 Step 22
        Color Rand(1,255),Rand(1,255),Rand(1,255)
        Line x,y,x,y+20
        Line x,y,x+20,y
        Color Rand(1,255),Rand(1,255),Rand(1,255)
        Line x+20,y,x+20,y+20
        Line x,y+20,x+20,y+20
        Rect x+1,y+1,18,18,1
    Next
Next
Flip
Until KeyHit(1)
End



Who was John Galt?2010
Wow, it may be a little on the simple side for the code archives, but you lot are being somewhat harsh. Not everyone is an uber programmer, you know. Nor do they have to be.


Jesse2010
true, The code archives are not only for exceptionally talented programmers like puki and _Skully...
Or did I missed something in the rules?


puki2010
I never put him down - I just added a Blitz3D one, then sort of played with it out of interest. I made a few more, but didn't post them.


TaskMaster2010
I do not know what the "rules" are. But, we could easily fill the code archives section with little snippets of code that anybody could write.

I don't feel that it is the purpose of the code archives. Maybe it is, I do not know. I just know that when I look through the code archive, I am looking for something useful, that I could not whip up myself in 2 minutes.

If the general consensus is that the code archives should be used for very basic stuff, then so be it. It is not my code archives to manage. I retract my previous statement.


Jesse2010
the code archives is proportionally useful to the skill level of the programmer in need of something here. A beginner user will find the code quite useful even 1 line code. The problem is that as soon as we start to improve our skills we begin to find even our own old code embarrassing to share and while we can now look at our old code and say that it is too stupid to look at much less share, I looked at the first few pages code archives' and learnt they are full of examples with similar code posts yet no one complained. The thing is that the more skilled we become the less useful we find the code archives to be and we look at code like this as an insult to our intelligence but we are not being open minded about beginners.

Bottom line is that this issue should be addressed by BRL but at last it seems we are beating on a dead horse. Technology and society changes but everything here seems to remain frozen in time.


Andy_A2010
In addition to what Jesse said, while Blitz2D, Blitz+, and Blitz3D are aging products, they are still new languages to those who just purchased a Blitz product.

The code archives are not only for the 'veteran' Blitz programmer but for 'noobs' as well. When I first purchased BlitzPlus, the code archives were the best examples of how to get things working, especially since the Blitz manuals are not the most lucidly written manuals ever produced (that's why I haven't splurged for Bmax).

For those individuals who think the simple program snippets are beneath them, I would suggest they make their own 'superior' contributions and leave all others in awe of their 'leetness'.

Nobody starts out as an expert, at some point in our lives we all started out as a 'noob'.


Who was John Galt?2010
I think the ideal answer would be to have a 'simple' or 'beginner' section in the archives, that way everyone can contribute and benefit.


Axel Wheeler2010
I think the answer is that it should be useful to someone, including beginners. But in order for that to happen there has to be some description of why it might be useful; that's what's really missing here. The author of any item in the code archives should include a description of what the code does and why it might be useful to someone.

I suspect if Jankupila had done that skully and taskmaster wouldn't have had a problem with it.

So, Jankupila, keep going; just be sure to include a little write-up.


_Skully2010
how about three buttons that act like votes
[beginner] [intermediate] [advanced]

then they will sort themselves


_Skully2010
Double post {snip}


Jesse2010
and How about a vote system that if the code does not get any votes with in a six month period gets deleted or gets dumped in to a useless bin/section? or a vote to determine if it gets deleted or not?


_Skully2010
How about

[Delete it, its crap] [beginner] [intermediate] [advanced]

Don't get me wrong I'm all for having beginner stuff, but when you are looking for valuable code and don't have a search function its essential to keep things relevant and meaningful.


TaskMaster2010
There is a beginners area in the forums already.

Code snippets like this belong there. Not really useful other than a learning tool for a very very beginner.


Jesse2010

There is a beginners area in the forums already



That is just as relevant as saying "there is a programming section in the forum already". Why post anything here?


Yasha2010
when you are looking for valuable code and don't have a search function


I have no idea why it was put in Blitz3D programming, but: http://www.blitzbasic.com/Community/posts.php?topic=88773

Really ought to be in the toolbox...


_Skully2010
I wasnt saying that you cant search by other means... you can isolate google to a site for example, but its not built into the archive.


Code Archives Forum