Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Codea - Making Areas where your character can't go

edited December 2016 in Questions Posts: 1

I am making a simple game and I need a little help. I have made this code over here and I would like it if I my player (circle) wasn't able to move through these the sprites that look like walls. I have been pretty clueless so far and I would like if someone showed me what I needed to do. If someone could look over my code and add something so that my sprite couldn't move through sprites, that would be very much appreciated. :)

P.S: I will post the code shortly. Even before I do, could you please still give an example on how I could make this happen? Thx.

Comments

  • dave1707dave1707 Mod
    Posts: 7,553

    @SabrinaGiroux Are you after something like this. Hold the iPad flat and tilt it to move the Guy in any direction.

    displayMode(FULLSCREEN)
    supportedOrientations(PORTRAIT_ANY)
    
    function setup()
        tab={}
        for z=1,20 do
            c=physics.body(CIRCLE,30)
            c.x=math.random(WIDTH)
            c.y=math.random(HEIGHT)
            c.type=STATIC
            table.insert(tab,c)
        end
        c=physics.body(CIRCLE,30)
        c.x=300
        c.y=300
        c.gravityScale=0
    end
    
    function draw()
        background(40, 40, 50)
        fill(198, 226, 226, 255)
        for a,b in pairs(tab) do
            sprite("Small World:Court",b.x,b.y,60,60)
        end
        sprite("Platformer Art:Guy Standing",c.x,c.y,60,60)
        c.linearVelocity=vec2(Gravity.x*1000,Gravity.y*1000)
    end
    
Sign In or Register to comment.