Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flying enemies #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
816 changes: 755 additions & 61 deletions Real Ninja.yyp

Large diffs are not rendered by default.

Binary file modified fonts/fntScore/fntScore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17,010 changes: 15,477 additions & 1,533 deletions fonts/fntScore/fntScore.yy

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions objects/oBird/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// @description Insert description here
// You can write your code in this editor
hsp = 10;
vsp = 10;
walksp = 0.5;
hp = 1;
imageDelay = 40;
dirDelay = 10;
vspd = 1;
hspd = 1;
95 changes: 95 additions & 0 deletions objects/oBird/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/// @description Insert description here
// You can write your code in this editor


vsp = vsp; //move by gravity so that it goes down on the wall, the oPlayer's gonna go up if it's vsp-grv;
//How poisition workds in this studio: the more y coordinate is bigger, the lower the object itself is.
if (x<= 55 or x >= 2040) or (y <= 318 or y >= 720) {
x = random_range(56,2039);
y = random_range(319,719);
}
dirDelay--;
if (dirDelay<0){
vspd = sign(random_range(-1,1));
hspd = sign(random_range(-1,1));
dirDelay = 10;
}

x = x + vspd * 7;
y = y + hspd * 7;
//Horizontal Collision
// if (place_meeting(x-10,y,oWall)) //if there's about to be a collision between oWall and oPlayer
// {
//There's a libble bit of pixels between oPlyaer and oWall.
//We wanna remove the spaces by place them in the closest position.
/*while (!place_meeting(x+sign(hsp),y,oWall)) { //sign(): return 1 or 0 depending on if hsp is positive or negative
x = x + sign(hsp); //increase/decrease x to 1
}*/
//hsp = 0;
//if there's no space between them = if they meet each other
//move the opposite
// hsp *= -1;

//}
/* if (place_meeting(x+hsp,y,oWall2)) //if there's about to be a collision between oWall and oPlayer
{
//There's a libble bit of pixels between oPlyaer and oWall.
//We wanna remove the spaces by place them in the closest position.
/*while (!place_meeting(x+sign(hsp),y,oWall2)) { //sign(): return 1 or 0 depending on if hsp is positive or negative
x = x + sign(hsp); //increase/decrease x to 1
}*/
//hsp = 0;
//if there's no space between them = if they meet each other
//move the opposite
// hsp *= -1;

// }


//Vertical Collision
/*if (place_meeting(x,y+vsp,oWall)) //if there's about to be a collision between oWall and oPlayer
{
//There's a libble bit of pixels between oPlyaer and oWall.
//We wanna remove the spaces by place them in the closest position.
/*while (!place_meeting(x,y+sign(vsp),oWall)) { //sign(): return 1 or 0 depending on if hsp is positive or negative
y = y + sign(vsp); //increase/decrease x to 1
}*/

//if there's no space between them
// vsp = 0;
// }
// if (place_meeting(x,y+vsp,oWall2)) //if there's about to be a collision between oWall and oPlayer
//{
//There's a libble bit of pixels between oPlyaer and oWall.
//We wanna remove the spaces by place them in the closest position.
/*while (!place_meeting(x,y+sign(vsp),oWall2)) { //sign(): return 1 or 0 depending on if hsp is positive or negative
y = y + sign(vsp); //increase/decrease x to 1
}*/

//if there's no space between them
// vsp = 0;
// }*/


//Animation
if (!place_meeting(x, y+1,oWall)) {//why typing the same code: just trying to keep things straightforward

image_speed = 0; //multiply speed of sprites * 0
//if (sign(vsp) > 0) sprite_index = 0; else sprite_index = 1;
}
else
{
//image_speed = 1;
}


if (hsp != 0) image_xscale = sign(hsp);

imageDelay--;
if (imageDelay < 0){
image_index = 0;
}
if (imageDelay < -5){
imageDelay = 5;
image_index = 1;
}
13 changes: 13 additions & 0 deletions objects/oBird/Step_1.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// @description Insert description here
// You can write your code in this editor
if (hp <= 0) {
with(instance_create_layer(x,y,layer,oBirdDead)){
//direction = other.hitfrom; // apply to where where it hits from bullet, watch part 4

hsp = 3 //lengthdir_x(3, direction);
vsp = 3 //lengthdir_y(3, direction); //or direction-2:for a little bit of shaking
if (sign(hsp) != 0) image_xscale = sign(hsp);
}
instance_destroy();

}
58 changes: 58 additions & 0 deletions objects/oBird/oBird.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions objects/oBirdDead/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// @description Insert description here
// You can write your code in this editor
9 changes: 9 additions & 0 deletions objects/oBirdDead/Step_1.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// @description Insert description here
// You can write your code in this editor
/// @description Insert description here
// You can write your code in this editor
lasting = 100;
lasting -= 1;
if (lasting < 0){
instance_destroy();
}
48 changes: 48 additions & 0 deletions objects/oBirdDead/oBirdDead.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions objects/oBullet/Collision_74dd2063-cbab-4092-9606-25904950e26a.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// @description Insert description here
// You can write your code in this editor
with (other) //depending on when and how it's used: it will apply to the enemy
{
hp--;
flash = 3;
sprite_index = 1;
audio_play_sound(sndBullet, 0, 0);
oGun.dead++;
}


instance_destroy();
10 changes: 10 additions & 0 deletions objects/oBullet/oBullet.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion objects/oEnemyDead/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (done == 0){
image_index = 1;
}
//There's a little bit of pixels between oPlyaer and oWall.
//We wanna remove the spaces by place them in the closest position.
//We wanna remove the spaces by placing them in the closest position.
while (!place_meeting(x,y+sign(vsp),oWall)) { //sign(): return 1 or 0 depending on if hsp is positive or negative
y = y + sign(vsp); //increase/decrease x to 1
}
Expand Down
8 changes: 5 additions & 3 deletions objects/oGun/Step_1.gml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ else{
image_angle = controller_angle; //
}

firingdelay -= 1;

recoil = max(0, recoil - 1);

if (firingdelay = 0){
if (firingdelay < 0){
with(oPlayer){
instance_create_layer(x - 20, y + 20, "Player",oTriggered);
}
Expand All @@ -35,7 +35,9 @@ if(oTriggered){
y = oPlayer.y - 50
}
}

if(firingdelay > -1){
firingdelay -= 1;
}
if (mouse_check_button(mb_left) || gamepad_button_check(0, gp_shoulderlb)) && (firingdelay < 0){
recoil = 4;
firingdelay = 100;
Expand Down
2 changes: 1 addition & 1 deletion objects/oPlayer/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

vsp = 0; //vertial speed
grv = 0.1; //gravity
walksp = 3; //walking speed
walksp = 4; //walking speed
hsp = walksp;

controller = 0;
45 changes: 21 additions & 24 deletions objects/oPlayer/Step_0.gml
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
//Error: the game gets slow when the player's moving
//Get Player Input
key_left = keyboard_check(vk_left) || keyboard_check(ord("A")); //return 1 or 0
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_up) || keyboard_check(ord("W"));
key_left = keyboard_check(ord("A")); //return 1 or 0
key_right = keyboard_check(ord("D"));
key_jump = keyboard_check(ord("W"));

if (key_left) || (key_right) || (key_jump){
controller = 0;
}

if (abs(gamepad_axis_value(0,gp_axislh) > 0.2)){
key_left = abs(min(gamepad_axis_value(0, gp_axislh),0));
key_right = max(gamepad_axis_value(0,gp_axislh),0);
controller = 1;
}

if (gamepad_button_check_pressed(0, gp_face1)){
key_jump = 1;
controller = 1;

}
//Calculate Movement
var move = key_right - key_left; //depending on 1, 0, it goes left or right
/*if(key_left){
x += hsp;

}else if(key_right){
x -= hsp;
}*/


hsp = move * walksp; //4 pixels to the right/left

vsp = vsp + grv; //move by gravity so that it goes down on the wall, the oPlayer's gonna go up if it's vsp-grv;
hsp = walksp * move; //4 pixels to the right/left

vsp = vsp + grv; //move with gravity so that it goes down on the wall, the oPlayer's gonna go up if it's vsp-grv;
//How poisition workds in this studio: the more y coordinate is bigger, the lower the object itself is.

if (place_meeting(x,y+1,oWall)) && (key_jump){ //if oPlayer's on the foloor and player presses the jump button
if (place_meeting(x,y+1,oWall)) && (key_jump){ //if oPlayer's on the floor and player presses the jump button
vsp = -4;
}

Expand All @@ -36,7 +30,7 @@ if (place_meeting(x+hsp,y,oWall)) //if there's about to be a collision between o
{
//There's a libble bit of pixels between oPlyaer and oWall.
//We wanna remove the spaces by place them in the closest position.
while (!place_meeting(x+sign(hsp),y,oWall)) { //sign(): return 1 or 0 depending on if hsp is positive or negative
while (!(place_meeting(x+sign(hsp),y,oWall))) { //sign(): return 1 or 0 depending on if hsp is positive or negative
x = x + sign(hsp); //increase/decrease x to 1
}

Expand All @@ -56,9 +50,14 @@ if (place_meeting(x,y+vsp,oWall)) //if there's about to be a collision between o

//if there's no space between them
vsp= 0;

}


y = y + vsp;



//Animation
if (!place_meeting(x, y+1,oWall)) {//why typing the same code: just trying to keep things straightforward
sprite_index = sPlayerA;
Expand All @@ -76,5 +75,3 @@ else
}

if (hsp != 0) image_xscale = sign(hsp);


Loading