Understanding the language, error messages, etc.
by phi » Sat Apr 19, 2014 8:08 pm
I am working on a game concept where I need to draw a lot of trapezoids.
I would like to fill four lines to form a solid trapezoid.
Something like this:
- Code: Select all
gb.display.beginPath();
gb.display.drawLine(xStart, yStart, xEnd, yEnd); //line1
gb.display.drawLine(xStart, yStart, xEnd, yEnd); //line2
gb.display.drawLine(xStart, yStart, xEnd, yEnd); //line3
gb.display.drawLine(xStart, yStart, xEnd, yEnd); //line4
gb.display.fill();
Is there a general fill() function or something similar?
-
phi
-
- Posts: 50
- Joined: Sun Mar 23, 2014 1:48 pm
- Location: Germany
by rodot » Sat Apr 19, 2014 8:14 pm
You can split you trapezoid in two triangles to be able to use the following function:
- Code: Select all
fillTriangle(x0, y0, x1, y1, x2, y2);
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by phi » Sat Apr 19, 2014 9:07 pm
This will work as well. Thanks
-
phi
-
- Posts: 50
- Joined: Sun Mar 23, 2014 1:48 pm
- Location: Germany
by rodot » Sat Apr 19, 2014 9:15 pm
You're welcome
I never used this function yet, I don't know how efficient it is. when you say that you have to draw a lot of trapezoid, what do you mean by
a lot ?
Just out of curiosity, what is your game about?
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by phi » Sat Apr 19, 2014 9:49 pm
It is not that spectacular.
I want to create a pseudo 3D engine (like Outrun or Hang On).
It was one of the first things that came to my mind after seeing the Gamebuino project.
The proper 3D engine has already been done by myndale so I am going for pseudo 3D.
It will feature hills and slopes and uses said trapezoids for the terrain.
I don't know if my method is very efficient (there are several approaches) and we will see if it works well on the device. For now I am going to prototype the engine in JS and will port it later.
-
phi
-
- Posts: 50
- Joined: Sun Mar 23, 2014 1:48 pm
- Location: Germany
by adekto » Sat Apr 19, 2014 9:56 pm
u may be able to do something similar to scanline but ur triangulation may work better
bit of a side-track but worth looking into there is a race game called v-rally thats has a gameboy port wich has ur graphics style
-
adekto
-
- Posts: 448
- Joined: Tue Feb 25, 2014 9:47 pm
- Location: belgium
by Myndale » Sat Apr 19, 2014 10:18 pm
Awesome, having nostalgic flashbacks to Pole Position now
Looking forward to seeing what you come up with!
-
Myndale
-
- Posts: 507
- Joined: Sat Mar 01, 2014 1:25 am
by phi » Sat Apr 19, 2014 10:24 pm
The line approach tends to look a bit frayed but it sure is an alternative.
Here is a nice article on pseudo 3d engines.
http://www.extentofthejam.com/pseudo/@myndale
could you test the performance of triangle scaling if you are bored or something (no hurry)
-
phi
-
- Posts: 50
- Joined: Sun Mar 23, 2014 1:48 pm
- Location: Germany
by erico » Sat Apr 19, 2014 10:27 pm
I was going to raise that same article
IT is a great read and should help that front.
-
erico
-
- Posts: 671
- Joined: Thu Mar 27, 2014 9:29 pm
- Location: Brazil
-
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 44 guests