I need help making a faster way to draw this...

lmao if you had constantly refreshed your page you would’ve seen me stupidly trying to figure out how to work it, lol. I got it now ^ ^

Soooo, where are you going to go from here? layers? 3D? movement?

I need help again :\
This time with my character and how to detect if he should fall or not
I’ve tried making a way to have the game check if there’s a block underneath the self.y of the character and if it’s nil, to change the self.floor to the top of the block that’s underneath.
This seems to be much easier to detect if you use sprites but, yeah…

if self.y - 32 > self.floor then
    self.y = self.y - self.vel
end

You could try using the physics engine… But that would make EVERYTHING physics-y. (All the blocks…)

Well, @Jordan your pretty smart, so in your opinion would the game work better or make more sense of I used physics?

Just thinking about it, you could use fixed EDGEs on the top of every block, and it wouldn’t mess with the gameplay. I will try and write something up for you (BUT YOU TRY AND BEAT ME)
P.S. Character? Hmmm… Any code for my prying eyes?
P.P.S. That applies to @Andrew_Stacey too :wink:

Lol, he’s just a bunch of meshes put together to resemble the minecraft character for now :slight_smile:
He’s only colors. Lol, he’s under the class, “Joe”

(@RichGala1, are you jailbroken? If not, I have a little surprise for you)
Still, I kinda want to see you code, so I can modify it, and you don’t have to modify mine.

If I am then I don’t get a surprise?

If you are, do you own minecraft pocket edition? And here is another little surprise for you…


--# Main
-- MineCraft by Jordan Arenstein

function setup()
    world = worldCreate()
    ellipseMode(RADIUS)
end

function draw()
    background(0, 0, 0, 255)
    world:draw()
end

function touched(touch)
    world:touched(touch)
end

--# worldCreate


worldCreate = class()

function worldCreate:init()
    -- you can accept and set parameters here
    wWidth = WIDTH/32
    wHeight = HEIGHT/2/32
    local world = {}
    local id = {}
    local bid = {}
    local bodies = {}
    self.player = physics.body(CIRCLE, 25)
    self.player.position = vec2(WIDTH / 2, HEIGHT / 4 * 3)
    --blocks = {}
    img = readImage("Documents:Minecraft Tileset")
    --blocks["grass"] = mesh()
    --blocks["dirt"] = mesh()
    --blocks["stone"] = mesh() -- CHANGED IT ALL TO ONE MESH!!!
    self.blocks = mesh()
    self.blocks.texture = img
    for i = 1,wWidth do
        world[i] = {}
        for j = 1, wHeight do
            world[i][j] = math.random(6)
        end
    end
    
        for r,row in pairs(world) do
        id[r] = {}
        bid[r] = {}
        bodies[r] = {}
        for c,col in pairs(row) do
            id[r][c] = self.blocks:addRect(-16 + r*32,-16 + c*32,32,32)
            bodies[r][c] = physics.body(EDGE, 
                vec2((r - 1) * 32, c * 32), 
                vec2(r * 32, c * 32))
            bodies[r][c].restitution = .5
            if c == wHeight then
                self.blocks:setRectTex(id[r][c], 3/16,15/16,32/512,32/512)
                bid[r][c] = 1
            elseif c < (wHeight - 2) and c >= 7 and col > 5 then
                self.blocks:setRectTex(id[r][c], 1/16,15/16,32/512,32/512)
                bid[r][c] = 2
            else
                self.blocks:setRectTex(id[r][c],2/16,15/16,32/512,32/512)
                bid[r][c] = 3
            end
        end
    end
    self.world = world
    self.id = id
    self.bid = bid
    self.bodies = bodies
end

function worldCreate:draw()
    -- Codea does not automatically call this method
    self.blocks:draw()
    fill(255, 246, 0, 255)
    ellipse(self.player.position.x, self.player.position.y, 25)
end

function worldCreate:touched(touch)
    -- Codea does not automatically call this method
    if touch.state == ENDED and touch.y < HEIGHT / 2  then
        self.blocks:setRect(self.id[math.ceil(touch.x/32)][math.ceil(touch.y/32)], 0, 0, 0, 0)
        self.bodies[math.ceil(touch.x/32)][math.ceil(touch.y/32)]:destroy()
    end
    self.player:applyForce(vec2(touch.x, touch.y) - self.player.position)
    
end

I am jailbroken and I do own MCPE. I’m using their tiles :stuck_out_tongue: (cheater)
Ooh! Code! Checking it now :slight_smile:

Aaah. :slight_smile: I was going to suggest using the char.png file in the minecraftpe.app folder :wink: or (if this works) go here char

Holy crap!!! Man, I told myself I was going to sit down and learn about the physics engine one day! Tht’s freakin’ awesome!

I barely know it! Who thinks someone out there should write a tutorial on it?

can physics be applied to sprites/meshes? and if not, do physics objects only affect each other or can a regular rect() stop at an edge?

You have to apply them yourself, but it is pretty simple to do so. No, physics are in their own world. And you have to create floors and walls in there.

Notice my ellipse(self.player.position.x, self.player.position.y)? That is applying it to a shape

Sometimes it’s easier to learn from a step-by-step tut than an example like the physics lab so I agree that there should be a good tut. @Vega 's mesh tutorial was illuminating, if someone can make a physics tut like that it would be great

@RichGala1, what do you say about us working together, learning about the physics function, and writing it up?

what do you say about us working together, learning about the physics function, and writing it up?

Sounds like a brilliant idea. Do it!