Coder Social home page Coder Social logo

zelda's People

Contributors

coltonoscopy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zelda's Issues

cannot get the pots to disappear after throwing them

hey everyone,
I'm currently working on the assignment for Zelda remake. I've got everything working fine but im stuck on how to get the pots to disappear after your throw them. I have been trying to add a table.remove(self.objects, k) in the room:update(dt) section of the logic. below is my latest attempt:
(you can skip down to SEE BELOW FOR MY ATTEMPT)

function Room:update(dt)
-- don't update anything if we are sliding to another room (we have offsets)
if self.adjacentOffsetX ~= 0 or self.adjacentOffsetY ~= 0 then return end

self.player:update(dt)

for i = #self.entities, 1, -1 do
    local entity = self.entities[i]

    -- if entity is dead, skip the next code block
    if not entity.dead then
        -- if entity has been just defeated
        if entity.health <= 0 then
            -- mark entity as dead
            entity.dead = true
            -- spawn a heart with 10% probability
            if math.random(10) <= 7 then
                self:spawnHeart(entity.x, entity.y)
            end
        -- if entity has not been defeated yet
        else 
            entity:processAI({room = self}, dt)
            entity:update(dt)
        end

        -- collision between the player and entities in the room
        if self.player:collides(entity) and not self.player.invulnerable then
            gSounds['hit-player']:play()
            self.player:damage(1)
            self.player:goInvulnerable(1.5)

            if self.player.health == 0 then
                gStateMachine:change('game-over')
            end
        end
    end
end

----------------- SEE BELOW FOR MY ATTEMPT
for k, object in pairs(self.objects) do
object:update(dt)
local distance = 3*16

    -- trigger collision callback on object
    if self.player:collides(object) then
        if object.type == 'heart' then
            Event.dispatch('heartCollected')
        end
        object:onCollide()
        if object.consumable then
            table.remove(self.objects, k)
        end
    end

    if object.type == 'pot' and object.state == 'thrown' then
        -- wall collision check
        if self:wallsCollideWith(object) then
            table.remove(self.objects, k)
        end

        -- for each entity (enemy)
        for i = #self.entities, 1, -1 do
            local entity = self.entities[i]
            -- if entity is dead, skip the next code block
            if not entity.dead then
                if entity:collides(object) then
                    -- pot collided with enemy, so deal damage
                    entity:damage(1)
                    -- and destroy the pot, removing it from the objects table
                    table.remove(self.objects, k)
                end
            end     
        end
        
        if object.type == 'pot' and object.state == 'idle' and distance == true then
            table.remove(self.objects, k)
        end
    end
end
Timer.update(dt)

end

any advice would be extremely helpful. Im sure im missing something small but i've spent the whole day trying to do this one part of the assignment :((((

Error in love.graphics.stencil(function()

Hey I was currently going through the zelda code and when I run it without making any changes I got this stencil error
Error

src/world/Room.lua:214: Drawing to the stencil buffer with a Canvas active requires either stencil=true or a custom stencil-type Canvas to be used, in setCanvas.

Traceback

[C]: in function 'stencil'
src/world/Room.lua:214: in function 'render'
src/world/Dungeon.lua:152: in function 'render'
src/states/game/PlayState.lua:51: in function 'render'
src/StateMachine.lua:27: in function 'render'
main.lua:58: in function 'draw'
[C]: in function 'xpcall'

error

Error

src/Dependencies.lua:68: bad argument #2 to 'newSource' (string expected, got no value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.