Log In  
Follow
MaddoScientisto

I've been using the camera(x,y) function to move my camera viewport but now I can't do UI because print() and such work off world coordinates rather than screen coordinates, is there something that would allow me to offset coordinates from the camera position?
Something like screen.x, camera.x, etc

3 comments



I've been using this tutorial as my principal information for programming, since there's no picotron specific resource.

I'm experimenting with table-based classes, according to the guide I'm supposed to be able to create a base blueprint of an object and then instantiate it, but when I do so following the example, the object is not copied but instead it becomes a reference, because every change gets applied to the first object.

I made a sample project, first I try the guide's way, then I try it in a way I know works

enemies = {}
enemies2 = {}

enemy = {
	type = 0,
	sp = 1,
  	x = 0,
  	y = 0,
	dx = 0,
	dy = 0,
  	update=function(self)
    self.x += self.dx
    self.y += self.dy  
  end,
	draw=function(self)
		spr(self.sp, self.x, self.y)
	end
}

goblin = enemy --copy enemy class
goblin.sp = 2
goblin.type = 3
goblin.x = 6
goblin.y = 10

ogre = enemy  --copy enemy class
ogre.sp = 3
ogre.type = 4
ogre.x = 40
ogre.y = 50

function _init()
add(enemies, enemy)
add(enemies, goblin)
add(enemies, ogre)

add_enemy(16,16,4)
add_enemy(32,32,5)
add_enemy(64,64,6)

end

function add_enemy(new_x,new_y,sprIndex)
	add(enemies2, {
	type = 0,
	sp = sprIndex,
  	x = new_x,
  	y = new_y,
	dx = 0,
	dy = 0,
  	update=function(self)
   		self.x += self.dx
   		self.y += self.dy  
  	end,
	draw=function(self)
		spr(self.sp, self.x, self.y)
	end
})
end

function _draw()
	for e in all(enemies) do
		e:draw()
	end

	for en in all(enemies2) do
		en:draw()
	end
end

If I define the object in the add function then each object acts as independent object, is this how tables are supposed to function?

[ Continue Reading.. ]

2
19 comments



I'm drawing the map like this:

-- 2 is the layers count
for i=2,1,-1 do
   map(fetch"map/0.map"[i].bmp)
end

And I can check for collisions for map tiles with fget(mget(x/16,y/16)) to get the flag of the tile, all good here, except I can only check for collisions on the top layer, while every other layer is ignored.

How can I check for the flags on every layer?

2
4 comments