INTERNECIONLvl 62
- Windows
hello there! I am back and ready for action as I said in another discussion to add clarity. I am ready to talk. Let's hope you are willing to listen
hello there! I am back and ready for action as I said in another discussion to add clarity. I am ready to talk. Let's hope you are willing to listen
Zeldaria
ok good but I think you should still listen about that jump system
So how are ya doing? Zeldaria
*fixes gravity *
OMG BOING BOING BOING (it makes the player jump like a frog XD)
I see what you are trying to do. I wonder...
Also quick question, when you create a sprite using group.add(createSprite());
, what do you then call the sprite created?
I need to know so I can basically create a thing where you touch a group sprite and then after a set amount of time, it destroys that sprite alone;
I can probably do a group.remove(sprite) but I need the name of the sprite 1st
Zeldaria
because you havent defined the sprite as a variable, you have to access it like
group[numberthatspriteisinthegroup]
for example,
group[0].x += 1;
//moves the first sprite in the group
ah ok! Thx!
Here's the reason I asked: I'm adding platforms that, after you touch them, disappear after a few seconds and I needed to figure out how to y'know access the sprite so it is specific to what platform the player is touching and stuff
And--the BROKEN group is literally BROKEN
it won't destroy the sprite you touch at ALL!
HOW AM I SUPPOSED TO ONLY DESTROY A SPECIFIC SPRITE IN A GROUP WITHOUT HAVING TO DO A BUNCH OF NAMING JUNK?!
Zeldaria
hold on let me do a rlly easy asignment then Ill help
kkkk
Here's some more info: The BROKEN[0] sprite is created when you finish the tutorial and when you touch it, after 2 seconds or so it destroys BROKEN[0] but for some reason it won't get destroyed!
I even tried a lifetime thing but nooooooo it didn't work;
And when I try player.isTouching(BROKEN[0]) or player.isTouching(BROKEN) in the console it always says false!
Ok, im back, my school actually hand a jog a thon I forgot about and then I had to go to martial arts practice.
anyways, I think this error is because either
-broken[0] is not defined yet or
-your collision thingy moves the player's y when it touches the platform
so here is What you should try, tell me if it works or not.
for(var indx = 0; indx < BROKEN.length; indx++){
if(player.isTouching(BROKEN[indx])){
BROKEN[indx].velocityY = 5;//or whatever you want to happen
}
}
it works hooray!!
And now it doesn't again hmmmmmmmmmmmm
Here is the code currently:
//ALL the boring stuff
!<
camera.on();
var availableCLOUDS = 3;
var level = "tutorial";
var BACKGROUND_MUSIC = "sound://category_background/repitition.mp3";
var LIVES = 10;
var INFOtext = 5;
var spawnX = 200;
var spawnY = 200;
var player = createSprite(60, 360);
var cLoUdS = createGroup();
player.setAnimation("player_idle");
var ground = createGroup();
var OBSTACLEs = createGroup();
var ENDs = createGroup();
var TExt = createSprite(200, 200);
var BROKEN = createGroup();
TExt.setAnimation("text_1");
TExt.scale = 1.5;
playSound("sound://category_background/repitition.mp3", true);
ground.add(createSprite(60,365));
ground.add(createSprite(200, 230));
ground.setAnimationEach("ground_grass_1");
createEdgeSprites();
//declares the functions and makes sure stuff is animated good I guess
function draw() {
background("white");
ENDs.setAnimationEach("END_portal_thing");
ground.setAnimationEach("ground_grass_1");
ground.setScaleEach(0.3);
BROKEN.setScaleEach(0.3);
BROKEN.setAnimationEach("ground_grass_broken_1");
drawSprites();
move();
collide();
DIE();
clouds();
infoTEXT();
LEVELup();
CAMERAA();
}
function CAMERAA() {
if (player.y>=400&&level==1) {
camera.y=600;
}
}
//for the levels, when you advance
function LEVELup() {
if (player.isTouching(ENDs)) {
playSound("sound://category_jump/cartoon_synth_warp_jump.mp3", false);
stopSound(BACKGROUND_MUSIC);
ground.destroyEach();
ENDs.destroyEach();
cLoUdS.destroyEach();
availableCLOUDS = 3;
if (level=="tutorial") {
level = 1;
} else {
level = level+1;
}
if (level==1) {
BROKEN.add(createSprite(200, 200));
ground.add(createSprite(200, 80));
spawnX = 200;
spawnY = 40;
player.x = spawnX;
player.y = spawnY;
BACKGROUND_MUSIC = "sound://category_background/stride.mp3";
playSound(BACKGROUND_MUSIC, true);
}
}
}
//spawning clouds
function clouds() {
if (mouseWentDown("leftButton")&&availableCLOUDS!=0) {
cLoUdS.add(createSprite(World.mouseX,World.mouseY));
cLoUdS.setLifetimeEach(175);
availableCLOUDS = availableCLOUDS-1;
} else {
}
cLoUdS.setAnimationEach("cloud_1");
}
//tutorial text
function infoTEXT() {
if (INFOtext==4) {
TExt.setAnimation("text_2");
TExt.x = 125;
TExt.y = 300;
}
if (INFOtext==3) {
TExt.setAnimation("text_3");
TExt.x = 200;
TExt.y = 200;
}
if (INFOtext==2) {
TExt.setAnimation("text_4");
}
if (INFOtext==1) {
TExt.setAnimation("text_5");
}
if (INFOtext==0) {
TExt.setAnimation("text_6");
ENDs.add(createSprite(300, 300));
}
textFont("Garamond");
textSize(24);
text("LIVES: "+LIVES, 0, 15);
if (keyWentDown("enter")) {
INFOtext = INFOtext-1;
}
}
//ways of death and stuff
function DIE() {
if (player.isTouching(bottomEdge)&&level!=1) {
LIVES = LIVES-1;
player.x = spawnX;
player.y = spawnY;
player.visible = false;
stopSound(BACKGROUND_MUSIC);
console.log(("Oof! The player has died from FALLING! Now has "+LIVES)+" lives left!");
playSound("sound://category_alerts/comedy_game_over_1.mp3", false);
setTimeout(function(){
setTimeout(function(){
player.visible = true;
playSound(BACKGROUND_MUSIC, true);
}, 1000);
}, 1000);
}
}
//moving
function move() {
if (keyDown("right")) {
player.x = player.x+2;
player.setAnimation("player_walk");
player.mirrorX(+1);
} else if ((keyDown("left"))) {
player.x = player.x-2;
player.setAnimation("player_walk");
player.mirrorX(-1);
} else {
player.setAnimation("player_idle");
}
if (keyDown("up")){
player.y = player.y + 3 ;
player.setAnimation("player_jump");
if (player.isTouching(ground)| |player.isTouching(cLoUdS)| |player.isTouching(BROKEN)) {
playSound("sound://category_digital/boing_1.mp3", false);
player.y = player.y - 8;
player.velocityY = -15 ;
} else {
player.y = player.y - 3 ;
}
}
}
//collision and special platforms
function collide() {
player.collide(BROKEN);
player.collide(ground);
player.collide(cLoUdS);
while ((player.isTouching(ground))) {
player.velocityY = 0 ;
player.y = player. y - 0.1 ;
}
for(var indx = 0; indx < BROKEN.length; indx++){
if(player.isTouching(BROKEN[indx])){
BROKEN[indx].velocityY = 5;
}
}
player.velocityY = player.velocityY + 1.5;
}
*note: the | | is || but it would hide it if I put it in 'code way' so yeah :/
Including what Ackvonhuelio reccomended