Log In  
Follow
granly

Hi everyone!

I'm making a game where two players try to knock their opponent's balls off a table. Functionally it works just like pool, except instead of a cue ball you pick one of your balls on the table to shoot.

I'm stumped trying to make a game state where you can cycle through the balls you have on the table to pick which one you shoot.

I want to collect the xy of all p1's balls in a table, just once, each time p1 starts their turn. Is it possible to do that in the update function?

Currently my code looks like this, but it's not working as intended because it just keeps adding to the table infinitely as long as a ball meets the conditions:

function ballselect()
	foreach(balls, playerballs)
end

function playerballs(pb)
	if pb.ontable==true then --check ball still in play
		if player==1 then --check player
			if pb.c==12 then --check ball is p1 colour
				add(bc1,{
					x=pb.x,
					y=pb.y,
					n=count(bc1) --assign number to cycle thru?

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=163753#p)
1
2 comments



Hi everyone!

I'm sure this isn't as hard as it feels but for some reason I can't work out what I'm doing wrong!

Basically I want my player to select the location to start a countdown from, then race from there to the exit (which is in the top left corner near 0,0). The further away you start, the bigger your score.

This bit is okay. I just do:

flr(p.x-exit.x+p.y-exit.y)

And I get a nice round number that I can add to the score (647 at spawn).

But that number is too small, so I want to multiply it by 100:

flr(p.x-exit.x+p.y-exit.y)*100

I expect this to give me 64700 at spawn, and yet the new output is -831?

What am I doing wrong? Please help!

1
4 comments