BlitzPlus Polygons

Blitz3D Forums/Blitz3D Beginners Area/BlitzPlus Polygons

Newbunkle(Posted 2004) [#1]
Well, I just bought BlitzPlus and I'm impressed, but... I've searched through the command list in the graphics catagory and I can't find a polygon command!

How I wept... Had the demo included a command list, I would have known in advance! Curse them!

Does anyone know a good routine for drawing a polygon that I can use? I only need a shape with 3 to 5 sides - nothing huge.


Andy(Posted 2004) [#2]
http://www.blitzbasic.com/Manuals/_index_.php

Andy


Newbunkle(Posted 2004) [#3]
Thanks, must have missed that! The thing is... you've taken my wierd sense of humour too literally - you'll get used to it in time I assure you. I was going to buy BlitzPlus anyway!

Can't you help with the polygons thing then?


Perturbatio(Posted 2004) [#4]
You could load the points into an array, then use the line command to draw the poly. (or store the data in a file or data statement and read the coords in when needed)

[pseudocode]

graphics 800,600,16
setbuffer backbuffer()

Dim myPolyArray(4,2)

Cls

myPolyArray(1,1) = 10
myPolyArray(1,2) = 10
myPolyArray(2,1) = 40
myPolyArray(2,2) = 10
myPolyArray(3,1) = 40
myPolyArray(3,2) = 80
myPolyArray(4,1) = 10
myPolyArray(4,2) = 80

prevpoint = 4
for points = 1 to 4
		Line myPolyArray(points,1),myPolyArray(points,2),myPolyArray(prevpoint,1),myPolyArray(prevpoint,2)	
		prevpoint = points
next

text 10,150, "Press escape to exit"
Flip

while not keydown(1)
	
wend
end


[/pseudocode]

NOTE: this may not work straight away since I just knocked it up without blitz available.


Andy(Posted 2004) [#5]
>Thanks, must have missed that! The thing is... you've
>taken my wierd sense of humour too literally - you'll get
>used to it in time I assure you. I was going to buy
>BlitzPlus anyway!

The quality of communication is always determined by the communicator... In this case you! If you leave room for misunderstanding, you will be misunderstood! In this case I feel you left ample room!

http://www.blitzbasic.com/codearcs/codearcs.php?cat=1

Andy


Newbunkle(Posted 2004) [#6]
Maybe you're right Andy, but back to the polygons... I thought about it while I was at work (as you do). I thought I could try doing the following...

1. Find the two points with the lowest and highest 'x' values.

2. For each 'x', check each side to see if it crosses the x-axis - working out the y-values in the process.

3. Draw a vertical line from the lowest point to the highest.

I haven't thought of the code for it yet, but I think there's room to insert clipping of the polygons to fit the screen too.


mearrin69(Posted 2004) [#7]
Muppet,
Do a little searching on the net. I know there are tons of 2D vector type libs with source out there (from yesteryear). Polys, clipping to screen, transformations, union, difference, intersection, etc. Might be in another language but it shouldn't be too hard to convert to B+.
M


Difference(Posted 2004) [#8]
Try this Blitz code : Tood

Tood is not completed, but it does draw filled polygons.


turtle1776(Posted 2004) [#9]
Check out this non-user lib proggy:

Boids
http://www.policyalmanac.org/games/boids.zip

Specifically, check out the Polygon Sprite Editor and polygons.bb include file. It was written in Blitz 2D, so it should work with Blitz +, though sometimes there seems to be compatibility problems between B2D and B+ programs.


Newbunkle(Posted 2004) [#10]
Thanks guys! I'll check those out in detail later! I'd need to upgrade my computer before I could get Blitz3D, so I don't mind doing it a bit retro for now.

PS That's a cool project Mearrin! I've got Space Hulk, Genestealer and Deathwing (1st Edition) in my loft somewhere - I remember it well! I also remember the video game when I had my Amiga - I was awful at it. Good luck with that!