Jump to content

2D game


Html

Recommended Posts

Err... what is "the gfx" and "classic lines"?

Link to comment
Share on other sites

  • Replies 78
  • Created
  • Last Reply

Using what engine? With canvas you have to begin a path, then move the caret from the start of your line to the end

context.beginPath();context.moveTo(0,0); //Move the caret to (0,0) as the beginning of the linecontext.lineTo(100,100); //Draw a line to (100,100)

Link to comment
Share on other sites

You'll need to calculate the co-ordinates. I would draw the bottom line first, and remember it will be (length * the square root of 3) units tall.

function drawTriangle(context, x, y, width, filled) {	context.beginPath();	var height = Math.floor(width * Math.sqrt(3))	context.moveTo(x,y+height);	context.lineTo(x+width, y+height);	context.lineTo(x+Math.floor(width / 2), y);	if (filled) context.fill();	else {		context.closePath();		context.stroke();	}}

Link to comment
Share on other sites

Apparently I need to log in to view that page :)

Link to comment
Share on other sites

Are you sure?

Not FoundThe requested URL was not found on this server.Apache Server at schoolsareforfish.net
Link to comment
Share on other sites

That's a cool game :)Though I can't say my chances of winning were too attractive at 0.07716049382716049% lolI like the fact that you can get the info by clicking the buttons on the left

Link to comment
Share on other sites

Well its sort of discouraging but with a bit more information I suppose it will be fine.

Link to comment
Share on other sites

Well, you'll have to give each of the objects a defined position (X and Y).Then you have to make an algorhithm that tells the program that while the object's X is greater than the other object's X, keep subtracting 1 pixel to the X value, while the object's X is less than the other object's X, keep adding 1 pixel to the X value. Do the same with the Y values. As for detecting collision, it's a little complicated. The simplest way, would be to say that when the X position of the object is equal to the X position of the other object AND the Y position of the object is equal to the Y position of the other object, then they have collided. Of course, this means that they'll only actually "collide" once they're inside eachother. A more complex collision test is hard to explain, but try to visualize it in your head and come up wtih the solution yourself.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...