Random Level Generator For Squidio

2018-02-05 00:00:00

By

Matthew Deig

Tags:

Code

    function new_world ()
        obs = 0
        level_num_obs = level_num_obs + level_mul
        if new_game == 1 then
            starting_pixels = 350
            while obs <= level_num_obs do

                world_build_check = math.random() * 100

                if ( ( world_build_check - 40 ) < 0 ) then
                    new_block_speed = math.random(-1 * block.max_velocity, block.max_velocity)
                    if ( new_block_speed < 0 and new_block_speed > -1 * block.min_velocity ) then
                        new_block_speed = math.random( -1 * block.max_velocity, -1 * block.min_velocity)
                    elseif ( new_block_speed > 0 and new_block_speed < block.min_velocity ) then
                        new_block_speed = math.random( block.min_velocity, block.max_velocity )
                    else
                        new_block_speed = block.min_velocity
                    end
                    table.insert ( world, { ['name'] = 'block', ['x'] = math.random(block.width, love.graphics.getWidth() - block.width),
                                            ['y'] = starting_pixels, ['width'] = block.width, ['height'] = block.height, ['velocity'] = new_block_speed,
                                            ['sprite'] = block.sprite} )
                    obs = obs + 1
                elseif ( ( world_build_check - 50 ) < 0 ) then
                    world_build_check = math.random() * 100
                    if ( ( world_build_check - 30 ) < 0 ) then
                        table.insert ( world, { ['name'] = 'left_stream', ['x'] = love.graphics.getWidth() - left_stream.width,
                                                ['y'] = starting_pixels, ['width'] = left_stream.width, ['height'] = left_stream.height, ['velocity'] = math.random(left_stream.min_force, left_stream.max_force),
                                                ['sprite'] = left_stream.sprite} )
                    else
                        table.insert ( world, { ['name'] = 'right_stream', ['x'] = 0,
                                                ['y'] = starting_pixels, ['width'] = right_stream.width, ['height'] = right_stream.height, ['velocity'] = math.random(right_stream.min_force, right_stream.max_force),
                                                ['sprite'] = right_stream.sprite} )
                    end
                    obs = obs + 1
                end

                    starting_pixels = starting_pixels - 62
            end

            starting_pixels = starting_pixels - 124
            table.insert ( world, { ['name'] = 'goal', ['x'] = goal.width,
                                            ['y'] = starting_pixels, ['width'] = goal.width, ['height'] = goal.height, ['velocity'] = 0,
                                            ['sprite'] = goal.sprite} )
            table.insert ( world, { ['name'] = 'goal2', ['x'] = love.graphics.getWidth() - goal.width,
                                            ['y'] = starting_pixels, ['width'] = goal.width, ['height'] = goal.height, ['velocity'] = 0,
                                            ['sprite'] = goal.sprite} )
        else
            starting_pixels = -62
            while obs <= level_num_obs do

                world_build_check = math.random() * 100
                if ( ( world_build_check - 40 ) < 0 ) then
                    new_block_speed = math.random(-1 * block.max_velocity, block.max_velocity)
                    if ( new_block_speed < 0 and new_block_speed > -1 * block.min_velocity ) then
                        new_block_speed = math.random( -1 * block.max_velocity, -1 * block.min_velocity)
                    elseif ( new_block_speed > 0 and new_block_speed < block.min_velocity ) then
                        new_block_speed = math.random( block.min_velocity, block.max_velocity )
                    else
                        new_block_speed = block.min_velocity
                    end


                    table.insert ( world, { ['name'] = 'block', ['x'] = math.random(block.width, love.graphics.getWidth() - block.width),
                                            ['y'] = starting_pixels, ['width'] = block.width, ['height'] = block.height, ['velocity'] = new_block_speed,
                                            ['sprite'] = block.sprite} )
                    obs = obs + 1
                elseif ( ( world_build_check - 50 ) < 0 ) then
                    world_build_check = math.random() * 100
                    if ( ( world_build_check - 30 ) < 0 ) then
                        table.insert ( world, { ['name'] = 'left_stream', ['x'] = love.graphics.getWidth() - left_stream.width,
                                                ['y'] = starting_pixels, ['width'] = left_stream.width, ['height'] = left_stream.height, ['velocity'] = math.random(left_stream.min_force, left_stream.max_force),
                                                ['sprite'] = left_stream.sprite} )
                    else
                        table.insert ( world, { ['name'] = 'right_stream', ['x'] = 0,
                                                ['y'] = starting_pixels, ['width'] = right_stream.width, ['height'] = right_stream.height, ['velocity'] = math.random(right_stream.min_force, right_stream.max_force),
                                                ['sprite'] = right_stream.sprite} )
                    end
                    obs = obs + 1

                end
                starting_pixels = starting_pixels - 62

            end

            starting_pixels = starting_pixels - 124
            table.insert ( world, { ['name'] = 'goal', ['x'] = goal.width,
                                            ['y'] = starting_pixels, ['width'] = goal.width, ['height'] = goal.height, ['velocity'] = 0,
                                            ['sprite'] = goal.sprite} )
            table.insert ( world, { ['name'] = 'goal2', ['x'] = love.graphics.getWidth() - goal.width,
                                            ['y'] = starting_pixels, ['width'] = goal.width, ['height'] = goal.height, ['velocity'] = 0,
                                            ['sprite'] = goal.sprite} )

        end


    end

What does it do

This function for the game will generate new table objects for the level after the goal marker shows up on the screen. I wanted it to be a weighted random so I just did some random check and minus out the chance of it happening. Some of my older version used a range check on the random number, but the results were not desired of what I wanted.

It places the hit object, stream object, and the goal object. The player is spawn at the bottom of the screen. Then I take the starting pixel which is roughly the middle of the screen and go up the screen until I hit the maxium of objects for the level.

I feel the function is a little wielding but it got the job done.

Spicy Chicken

2017-06-11 00:00:00

By

Matthew Deig

Tags:

What is needed

Chicken breast or any type of chicken Sriracha sauce Cider Vinegar Kansas City Steak Rub (This is a name of the spices from a local store brand but whats in it is salt, garlic, onion, paprika)

Pre-work

I let the chicken marinade in the Cider Vinegar and the Sriracha sauce. The Cider Vinegar is for tenderizing the chicken and Sriracha sauce is for the spice. For the cider Vinegar I put in just enough to bath the Chicken. Then Sriracha sauce I try to coat the whole chicken. Putting too much in would make it way spicy. I don’t have a set amount for these I just eye ball it.

Then I let the chicken sit in the marinade for 15 to 30 minutes but it might even better to let it sit over night.

Cooking

I heat up the grill to something like 200 degree fahrenheit. I place the chicken on the grill then I put the Kansas City Steak Rub on it. Let it cook for a little while then flip the chicken and put Kansas City Steak Rub on it again. Then I just cook till it is done.

Picture

20170408_200400.jpg

Simple Sine Wave

2017-06-01 00:00:00

By

Matthew Deig

Simple Sine Wave

I have like the sounds of synthesizers. I like the electronic music and chipmusic. I own a few synths. They are more cheap portable ones. I have the gakken MKII, nebulophone, monotron delay, and the pocket miku. I also messed with some audio DAWs.

I figure I try to make my own software synth. Just to learn more how the sounds are made and learn some sound processing on the way. So far I took some source code snippets and paste together a small simple sine wave generator that will play ten note scale into alsa.

Something I learn that to go up the scale you mulply your scale modifier, to go down you dived it.

I think the next step of this exercise is to add some user input for the notes and make a few effects.

Simple sine wave will kick it off