Hello fellow coders,
As I mentioned before, I’m coding frogger and want a nice road. I want it to not be repudiative, so I don’t want to tile an image, which i’ve done and looks alright, but not high enough for my standards. Right now, this is my code. On estimation, it would take 5.25 hours to render on my iPad 2.
Road = class()
function Road:init()
self.lanes = 10
self.lly = 0
--self.pavement = pavement()
self.pavementdots = makeArray(WIDTH)
for x = 1, WIDTH do
for y = 1, HEIGHT/7*5 do
self.pavementdots[x][y] = math.random(125)
end
end
self.pavement = image(WIDTH,HEIGHT/7*5)
for x = 1, WIDTH do
for y = 1, HEIGHT/7*5 do
clearOutput()
print(x.."\
"..y)
print(WIDTH.."\
".. HEIGHT)
self.pavement:set(x,y,self.pavementdots[x][y],
self.pavementdots[x][y],
self.pavementdots[x][y],255)
end
end
end
function Road:draw()
--draw the pavement
sprite(pavement,0,HEIGHT - HEIGHT/7*6)
--draw the lines
strokeWidth(8)
for j = 1,(self.lanes-1) do
self.lly = (HEIGHT - HEIGHT/7*6)+((HEIGHT/7*5)/(self.lanes))*j
for i = 0, WIDTH/50 do
sline = i * 50
line(sline, self.lly,sline+25,self.lly)
end
end
end
function Road:touched(touch)
end
I’ve tried different methods, but I can’t get it fast. I’m wondering if meshing it is the solution… Although it’s kind of hard for me to understand meshes… Can someone please help?
Thanks!