Hi again guys! I have been trying to make 2d terrain for my game, made out of vec2s and sprites, it seems as if I’m doing something wrong though.
Code:
-- Char
function setup()
print("Hello World!")
char = vec2(100,200)
charW = 10
charH = 75
touchx = 0
hurt = false
blocks1 = {}
x = 20
for i=1, 60 do
table.insert(blocks1, vec2(x, math.random(1, 13)))
x = x + 20
jump = false
fall = true
end
end
function draw()
if fall == true then
char.y = char.y - 1
end
background(19, 19, 19, 255)
xChar:draw()
-- WIP code for character
if touchx > char.x then
char.x = char.x + 1
charW = -10*3
end
if touchx < char.x then
char.x = char.x - 1
charW = 10*3
end
-- This sets the line thickness
strokeWidth(5)
--for b=1, #blocks1 do
--tint(47, 36, 30, 255)
--sprite("Documents:Star", blocks1[b].x, blocks1[b].y, 20, 200)
--end
-- Do your drawing here
for i, v in ipairs(blocks1) do
v.y = blocks1[i].y
v.x = blocks1[i].x
sprite("Documents:Star", blocks1[i].x, blocks1[i].y, 20, 200)
if --math.abs(blocks1[i].x - char.x)<charH/2 --and
math.abs(v.y - char.y)< charH/2
then fall = false
else
fall = true
end
end
end
function touched(touch)
touchx = touch.x
end