We do this because our function will use fractional positions. "floor()" returns the number rounded down, while "ceil()" does the opposite. We'll use this code:įloat x1 = rand(vec2(floor(p.x),floor(p.y))) įloat x2 = rand(vec2(ceil(p.x),floor(p.y))) Now, for the perlin noise, we'll need to interpolate our noise. It also keeps alpha at 1 so we can see what we're doing. This will multiply the color to the horizontal position divided by 512 (to increase the color range). Gl_FragColor = texture2D( gm_BaseTexture, v_vTexcoord ) For now we'll try setting "gl_Fragment" to our new vector like so: Now (assuming you put the varying code in the fragment shader also), we can use "v_vPosition" in the fragment shader. We don't have to use attributes, but we will in this tutorial. So at the bottom of the shader (within the brackets ), we will set the shader to "in_Position.xy" to get the x and y components of the position attribute. Now, once we define "v_vPosition ", we can use it. Drag in a Set Score icon and fill it in as shown.įollow that with a Destroy Instance icon.ĭo the same for the other 2 asteroids with settings for the score that suit your mood.For our example, we will add a 2D varying vector (vec2) to both the vertex and fragment shaders, and we'll call it "v_vPosition" to follow the theme. The collision should be with the obj_roid_big. Add a collision event to the bullet object window. I am going to increase the score by 10 for a large asteroid, 20 for a medium asteroid and 30 for a small one. When the bullet hits an asteroid, we need to destroy the bullet and increase the score. ![]() Test that all of the asteroids destroy as they should. In the small asteroid object window, the collision event just needs to play the sound and destroy the asteroid. You will need to do the same for the medium sized asteroid except that you will create 3 small asteroids. Save and test what happens when you hit the asteroid. Now drag in a Create Instance icon and fill in the window as shown,Īdd another one of these and fill them in the same way.įinally drag in a Destroy Instance icon so that you have the following, Drag in a Play Sound icon and play the sound that you created. Go to the large asteroid object window and add a Collision event with obj_bullet. Load one of the sounds for you to play when an asteroid is hit by a bullet call it snd_boom. Adjust the speed settings if you think it's needed. So the Move Free windows should be filled in as follows,Īdd 2 large asteroids to the edge of the room and run the game to check the movement. As the asteroids get smaller, they move more quickly. The only difference will be in the Move Free settings. The other 2 asteroids will need the same 2 events with the same actions. Drag in the Move Free icon and fill in the pop-up as below,Īdd an Outside Room event and drag in a Wrap Screen icon so that the asteroid will return to the opposite end of the screen when it reaches the edge. Open up the window for the big asteroid and add a Create event. Create 3 objects called obj_roid_big, obj_roid_medium, obj_roid_small. Associate the 3 asteroid graphics with the sprites. Medium asteroids split into 3 smaller asteroids when hit.Ĭreate 3 new sprites called spr_roid_big, spr_roid_medium, spr_roid_small. ![]() Large asteroids split into 3 medium asteroids when hit with a bullet.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |