Log In  
[back to top]

[ :: Read More :: ]

So I am trying to figure out a smart or elegant way to take a table of collidable objects and do collision checks on a each to all basis. But as I think about it, I am unsure how it will work out. I might have the first object colliding with two other objects. I could just have it handle collision on the first object from my list, and change its position appropriately. But then I don't do anything with the second collision.

Then, the second object from the array was colliding with the first, but now it isn't. So when we run the collision checks, we end up with no effect on this object. If I try to change the collision behavior to displace the two colliding objects instead of just the first one, then both might be out of collision with the third.

Anyways, I think I realize that all of this depends on how realistic the physics needs to be for your particular game. I just got confused in a hole of if then scenarios that began to escape my grasp. Any one have thoughts or methods for this type of problem?

P#36353 2017-01-22 15:13 ( Edited 2017-01-27 15:21)

[ :: Read More :: ]

it seems like all the drawing functions handle the floats fine by just truncating them anyway?

is there more memory overhead to store floats vs the int we get from flr?

what about the processor overhead from calling flr every time we want a random int?

P#35494 2017-01-11 21:59 ( Edited 2017-01-14 16:56)

[ :: Read More :: ]

i have to count frames a lot because i'm using them to base the timing for the rhythm game and the clock. rather than having some global variable i increment every update (which would then require some kind of modulo operation to check, say, if we are on an even numbered frame) i decided to use the closure technique to make a counter that resets after a certain number of frames.

function frame_looper(frames)
 local f = 0
 return function()
         f += 1
         if (f>frames) f=1
         return f
        end
end

here i have a function FRAME_LOOPER that takes a number of frames. it creates a local variable f and then returns an anonymous function that when called returns that local variable f. we can now make a variable that uses a frame_looper as a counter.

beat_counter = frame_looper(10)

now in my _update function i can just call beat_counter() and i'll get back a number from 1-10 depending on how many times the function has been called. rather than having to declare some random variable and set and increment it every update, that local variable f that was enclosed in the anonymous function gets generated every update.

i'm still new to all of this, but i was able to use the technique for two other parts of my code that also work on a counter like this.

function drum_beater(accents)
 local i,s = 0,0
 return function ()
    i += 1
    if (i > #accents) i=1

    if accents[i] then
      s=0
    else s=1 end   
    sfx(s)
 end
end

accent1 = {true,false,false,false}
drum = drum_beater(accent1)

--[[ moonbeat:
used in _draw to flicker the
moon sprite]]--
function moonbeat(b)
 local moon = {x=80,y=40,
               r=8,col=10}
 return function()
         if b == beat_frame then
          moon.r = 10
         end
         return circfill(
           moon.x,moon.y,
           moon.r,moon.col)
        end            
end

moon = moonbeat(0)

i can now just call drum() and moon() during _update and get the behavior i want, based on the beat counter for the moon, and using the closure to loop over a table on the drum beat.

P#31789 2016-10-26 00:22 ( Edited 2016-10-26 04:22)

[ :: Read More :: ]

Cart #31787 | 2016-10-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

Hello fellow Pico-nites! Its my first thread here on the forum and I'd like to greet all of you in the Lakota language:

Haú mitákuyepi. Iyúha čaŋtéwašteya napéčiyutapi.

One thing I've been excited about with this "fantasy console" is that I can imagine a fantasy world where game cartridges representing indian people in a positive way came out back in the 1980s. the only indian people i can even think of in video games are T.Hawk from Street Fighter and Turok... and i'm not even sure what he's supposed to be. not that they aren't positive representations, but here I can create something that is based on real living culture and not just a stereotype. i like imagining myself back as a little kid, going to the video store to rent some NES game and finding this on the shelf. And in our real world I can begin to make and distribute that fantasy not only to console users, but to whomever i please with the HTML export.

This is certainly a lesson in learning to work with limitations, but also the first successful "game" I've ever made too! I set out with some grand ideas about the indian game i wanted to make, but then Pico's limitations (and my own) helped me to craft an idea that seemed actually possible to me. A dance game based on pow-wow dancing!

Modern pow-wows have competitive dance events with prize money. Dancers are judged on many things, including their regalia, behavior, participation in the Grand Entry, and more. This game only focuses on whether or not the dancer can step in time to the beat. It is reflective only of men's traditional dance. There are a wide variety of dances, and perhaps future versions will include more game modes to reflect that.

I plan to add more game mechanics to make scoring more fun, like bonuses for not missing a beat, time limit, and possibly some kind of special moves. These will be more fantasy like with bells and whistles. Obviously I need to add more graphics, I plan to utilize my extra sprite space (no map) to put some extra love into animation.

My biggest problem right now is the music and sound. Currently, the beat sound effects are being triggered in the _draw() function on every frame where a beat should happen (every 10 frames). I found that I couldn't get the music() function to maintain a sync with my frame counter variable T, and therefore I wouldnt be able to detect if the buttons were being pressed in time with the rhythm. Any advice would be welcome. I want to be able to add some real music.

Thanks for reading and testing my game!

update: i fixed the tolerance for beat detecting and took out some modulo operations, maybe it will work better in browser now?

update 0.2b:

  • added game states (thanks misato), game now ends after 60 second time limit
  • added scoring based on timing of steps
  • code organized slightly better
  • added closures! maybe a little clumsily, but i was excited to be able to use this functional technique in lua and pico8.
    heres how i'm using it: simple counter using closures
P#31716 2016-10-25 01:45 ( Edited 2016-10-29 23:59)

Follow Lexaloffle:          
Generated 2024-03-29 10:04:42 | 0.067s | Q:12