How can I create a checkered floor pattern ?

Just starting out? Need help? Post your questions and find answers here.
Pot Noodle
Enthusiast
Enthusiast
Posts: 202
Joined: Sat Feb 18, 2012 10:21 pm
Location: Leicestershire

How can I create a checkered floor pattern ?

Post by Pot Noodle »

Hi guys, I am in the middle of an Intro for the D.B.F Xmas comp and have been stuck for ideas.
I decided on an old school type intro But now I am stuck.
I want do draw a checked floor pattern with blue and white squares on it and have it going off in to the distance.
I can't show my code at the moment, If someone has done this or knows how to do this
Your help would be great, I have part of some old code but I can't remember the rest of it.

Code: Select all

Procedure DrawGrid()
	
	Static Z
	Static X
	
	Static TX
	Static TY
	
	Static Clr
	Static Shade
	Static ClrStrt = 1
	
	Dim PolyTransform.f(8)
	
	For Z = 0 To Grid-2	
		
		ClrStrt = ClrStrt + 1
		If ClrStrt > 2 
			ClrStrt = 1
		EndIf
		
		Clr = ClrStrt
		For X = 0 To Grid-2
			
			Clr = Clr+1
			If Clr > 2 
				Clr = 1
			EndIf
			
			TX = (GridX(X,Z) / (GridZ(X,Z) - Move)) + HalfX
			TY = (GridY(X,Z) / (GridZ(X,Z) - Move)) + HalfY			
			
			PolyTransform(0) = TX
			PolyTransform(1) = TY
			
			TX = (GridX(X+1,Z) / (GridZ(X+1,Z) - Move)) + HalfX
			TY = (GridY(X+1,Z) / (GridZ(X+1,Z) - Move)) + HalfY			
			
			PolyTransform(2) = TX
			PolyTransform(3) = TY
			
			TX = (GridX(X+1,Z+1) / (GridZ(X+1,Z+1)-Move))+HalfX
			TY = (GridY(X+1,Z+1) / (GridZ(X+1,Z+1)-Move))+HalfY			
			
			PolyTransform(4) = TX
			PolyTransform(5) = TY
			
			TX = (GridX(X,Z+1) / (GridZ(X,Z+1) - Move)) + HalfX
			TY = (GridY(X,Z+1) / (GridZ(X,Z+1) - Move)) + HalfY			
			
			PolyTransform(6) = TX
			PolyTransform(7) = TY
			
			Shade = (TY/4) - 75
			If Shade<0
				Shade=0
			EndIf
			
			If Clr = 1
				SetColor(Shade,Shade,Shade)
			EndIf
			
			If Clr = 2
				SetColor( 0, 0,Shade)			
			EndIf		
			
			Poly(PolyTransform)
			
		Next
	Next
	
EndProcedure
Thanks
Last edited by Pot Noodle on Sun Dec 01, 2013 11:29 am, edited 3 times in total.
P.N.
Pot Noodle
Enthusiast
Enthusiast
Posts: 202
Joined: Sat Feb 18, 2012 10:21 pm
Location: Leicestershire

Re: Checkered floor

Post by Pot Noodle »

I can't believe it 67 views and no one has an idea :(
P.N.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Checkered floor

Post by IdeasVacuum »

Edit your post title - probably those 67 viewers thought your post is "This how to make a chequered floor", and not "How can I code a chequered floor?"
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Pot Noodle
Enthusiast
Enthusiast
Posts: 202
Joined: Sat Feb 18, 2012 10:21 pm
Location: Leicestershire

Re: Checkered floor

Post by Pot Noodle »

IdeasVacuum wrote:Edit your post title - probably those 67 viewers thought your post is "This how to make a chequered floor", and not "How can I code a chequered floor?"
Thanks, I'm not very good at this :(
P.N.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to create a checkered floor pattern

Post by IdeasVacuum »

You didn't change the post title to a question?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: How to create a checkered floor pattern

Post by em_uk »

Hi Pot Noodle.

The best thing to do is post a working example, or the framework to allow us to easily run what you're trying to do.

Just posting a procedure means that I have to figure out what you're doing and what I need to do in order to get it to work.

I skip through the question areas and copy and paste into PB and run, then I see if I can help out anyway.

:)
----

R Tape loading error, 0:1
Pot Noodle
Enthusiast
Enthusiast
Posts: 202
Joined: Sat Feb 18, 2012 10:21 pm
Location: Leicestershire

Re: How can I create a checkered floor pattern ?

Post by Pot Noodle »

The Procedure is not PB, It's some old code I found but it's not complete.
I posted it thinking it may give someone an idea.
I have searched long and hard for some way to do this but there is nothing out there :cry:
As for my code it would be as simple as calling a Procedure from the main loop to draw the pattern.
P.N.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Re: How can I create a checkered floor pattern ?

Post by Derek »

Ugly as sin bit of code but maybe you can get something from it.

Code: Select all

OpenWindow(0,0,0,1000,800,"",$ca0001)
CreateImage(0,4000,800)
StartDrawing(ImageOutput(0))
y=0
s=4
c=#White
Repeat
  For m=1 To s
    cc=c
    For n=0 To 4000 Step 16
      Line(n,y,16,1,cc)
      If cc=#White
        cc=#Blue
      Else
        cc=#White
      EndIf
    Next
    y+1  
  Next
  s+1
  If c=#White
    c=#Blue
  Else
    c=#White
  EndIf
Until y>=800
w=1000
x=0
For y=0 To 800
  GrabDrawingImage(1,0,y,4000,1)
  ResizeImage(1,w,1)
  DrawImage(ImageID(1),x,y)
  w+48
  x-24
Next
StopDrawing()
ImageGadget(1,0,0,1000,800,ImageID(0))
Repeat
Until WaitWindowEvent()=16
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How can I create a checkered floor pattern ?

Post by IdeasVacuum »

Can it be a static image?
Image

Image
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Pot Noodle
Enthusiast
Enthusiast
Posts: 202
Joined: Sat Feb 18, 2012 10:21 pm
Location: Leicestershire

Re: How can I create a checkered floor pattern ?

Post by Pot Noodle »

IdeasVacuum wrote:Can it be a static image?
Hi I was hoping to scroll it once I had drawn it but I am glad that this code draws it, Brill :D

Thanks guys for your help.
P.N.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How can I create a checkered floor pattern ?

Post by netmaestro »

I think the 3d drawing library from stargate here: http://purebasic.fr/english/viewtopic.php?f=12&t=53246
should serve your purpose. Specifically check example #4. You can create a checkered image and use this to tilt it back realistically at any angle you like. Note that there is a StructureUnion in the .pbi that the current compiler won't accept. It's not a problem, just comment out the StructureUnion and EndStructureUnion lines and leave the members as they are and you're good to go.

I made this in 5 minutes using the library:

Image
BERESHEIT
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How can I create a checkered floor pattern ?

Post by IdeasVacuum »

That's excellent netmaestro! 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How can I create a checkered floor pattern ?

Post by netmaestro »

You're close. You should have said, "That's excellent Stargate" :mrgreen:

All I did was know about it.
BERESHEIT
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: How can I create a checkered floor pattern ?

Post by davido »

I say excellent, ALL.

Thanks netmaestro, now I know about it, too. :D

A magnificent work by STARGÅTE.
DE AA EB
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How can I create a checkered floor pattern ?

Post by netmaestro »

I used my coming Gif Workshop to make an animation of movement:
Image
Look at it.
Relax.
Keep watching it.
You are starting to get sleepy... sleepy...
You are now fast asleep. You hear nothing but the sound of my voice.
Now, when I snap my fingers, you will awaken and feel refreshed.
And send me all your money :twisted:
BERESHEIT
Post Reply