1 / 19

Practice06 More GML

Practice06 More GML. Enemy Aircraft. Sprite: sprEnemy1 Mig41.gif Rotate the image in sprite editor (180 degree) Object: objEnemy1. EnemyController. sprEnemyController: Trigger.gif objEnemyController Make it “invisible” Place it somewhere in the Room1. Some Scripts. Enemy1Init

Download Presentation

Practice06 More GML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Practice06More GML

  2. Enemy Aircraft • Sprite: sprEnemy1 • Mig41.gif • Rotate the image in sprite editor (180 degree) • Object: objEnemy1

  3. EnemyController • sprEnemyController: Trigger.gif • objEnemyController • Make it “invisible” • Place it somewhere in the Room1

  4. Some Scripts • Enemy1Init • Vspeed = 10; • EnemyDisappear • Instance_destroy(); • EnemyControllerInit • alarm[0] = 30; • CreateEnemy1 • Instance_create(50, 0, objEnemy1); • alarm[0] = 30;

  5. Call Scripts • objEnemy1 • [EVENT] CREATE • [ACTION] Execute a script “Enemy1Init” • [EVENT] Outside Room • “EnemyDisappar” script • objEnemyController • [EVENT] Create • “EnemyControllerInit” • [EVENT] Alarm 0 • “CreateEnemy1” • Save the game and run it !

  6. Randomizing • In “CreateEnemy1” script instance_create(floor(random(screen_width)), 0, objEnemy1); screen_width 가 640이라면, random(screen_width)는 0 ~ 639.999999 사이의 값을 발생. floor는 소수점 이하 파트를 제거. alarm[0] = floor(random(51)) + 10; // 10 ~ 60 frames random • In “Enemy1Init” vspeed = random(8) + 2; // 2 ~ 9.99999 speed randomly • Save and Test it !

  7. Make them Collide • New script “PlayerEnemy1Collision” with (other) instance_destroy();myEnergy -= 30;if (myEnergy <= 0) then{    instance_destroy();} • Script “PlayerInit” myEnergy = 100; • objPlayer: • CREATE -> Call PlayerInit • Collision with objEnemy1 -> Call PlayerEnemy1Collision

  8. Shootout - 1 • New Script “BulletEnemyCollision” with (other){    // Lower enemy energy    myEnergy -= 50;    // Check if enemy energy is 0 or less    if (myEnergy <= 0)    {        // If so, destroy enemy.        instance_destroy();    }}// Destroy this bulletinstance_destroy(); • objBullet: Collision with Enemy1  Call the script

  9. Shootout - 2 • In Script “Enemy1Init” myEnergy = 100;

  10. Explosion • sprExplosion • Explosion.gif • 17 frame animation • objExplosion • [EVENT] Animation end (in “Other” group) • code: instance_destroy(); • objEnemy1 • [EVENT] DESTROY • [ACTION] Execute a piece of code instance_create(x, y, objExplosion); • objPlayer • [EVENT] DESTROY • similar to objEnemy1

  11. Centered Sprites - 1 • sprPlayer • change origin: (26, 39) • sprBullet • change origin: (8, 8) • sprExplosion • change origin: (35, 50) • sprEnemy1 • change origin: (32, 32)

  12. Centered Sprites - 2 • objPlayer • <space> key event • instance_create(x, y - 25, objBullet);

  13. Player Speed Control • New script “GameStart” global.playerMaxSpeed = 8; • objPlayer • CREATE event: call “GameStart” • <left> key: x -= global.playerMaxSpeed; • <right> key: x += global.playerMaxSpeed; • <up> key: y -= global.playerMaxSpeed; • <down> key: y += global.playerMaxSpeed;

  14. Energy Control • GameStart script global.playerMaxSpeed = 8;global.playerMaxEnergy = 100;global.enemy1MaxEnergy = 100;global.enemy1Damage = 30;global.bulletToEnemy1Damage = 50; • PlayerInit script: myEnergy = global.playerMaxEnergy; • Enemy1Init: myEnergy = global.enemy1MaxEnergy; • PlayerEnemy1Collision: myEnergy -= global.enemy1Damage; • BulletEnemyCollision myEnergy -= global.bulletToEnemy1Damage;

  15. Player Controller • sprPlayerController • SatelliteDish.gif • objPlayerController • Leave it visible !! (DRAW event should arise!) • [EVENT] Create : execute “GameStart” • New Script “CreatePlayer” myPlayer = instance_create(screen_width / 2, 400, objPlayer); • objPlayerController • [EVENT] Create: execute “CreatePlayer” • Remove objPlayer instance from the room • Place objPlayerController somewhere in the room • Try to run it !!

  16. Energy Bar - 1 DrawEnergyBar script pen_color = make_color(150, 150, 150);brush_color = make_color(150, 150, 150);x1 = 5;y1 = screen_height - 15;x2 = 110;y2 = screen_height - 5;draw_rectangle(x1, y1, x2, y2); if (instance_exists(myPlayer)){    pen_color = make_color(0, 0, 255);    brush_color = make_color(0, 0, 255);    x1 = 7;    y1 = screen_height - 13;    x2 = 7 + myPlayer.myEnergy;    y2 = screen_height - 7;    draw_rectangle(x1, y1, x2, y2);}

  17. Energy Bar - 2 • objPlayerController • DRAWING event • execute “DrawEnergyBar” script

  18. Galaxy Background • Background: bgrStars1 • Edit background button • Transform > Resize canvas: 200, 200 • Fill black for entire image • Select white color  Pencil  a few stars randomly (3 stars) • Room • backgrounds tab  background 0 • select background image “bgrStars1” • check “Visible when room stars”, “Tile Hor”, “Tile Vert” • uncheck “Draw background color” • Vert.speed = 3  make the stars to move

  19. Parallax • New background: bgStars2 • 200 x 200 • black background • 5 stars with some “gray” color • Make it “transparent” • In the Room • Background1  bgStars2 • Vert.speed = 2 • Try to run it !! • Try to add one more layer: bgStars3 • more darker stars • more slow speed than layer 1 and 2.

More Related