Score

J

Januxor

Guest
Ok so.. I made score and I put it to Persistent but its not the same when I change the room.
So.. what to do?
 
D

DarthTenebris

Guest
Please post some code and I'll see what I can do about it. (Create event, step, alarm, draw, etc.)
 
J

Januxor

Guest
draw:
draw_set_font(font_score);
draw_set_color(c_black);
draw_text(view_xview[0] + 32, view_yview[0] + 64,global.points);
create;
create: global.points=0;

obj_player collision with obj_coins:
global.points = global.points + 1;
instance_destroy();

btw I seen on the vid that he putted points so i putted points too ;D

edit: thats for score and this is for obj_player step event:
(this code isn't that good I just copied it cause I didn't know that and this is my first game btw)

Code:
{

    platform_collisions_step(obj_solid_bricks);
    
    if(place_free(x,y+1)){
    gravity = .5;
    } else {
    gravity = 0;
    }
    
    
    if (keyboard_check(vk_right) && place_free(x+1,y)) {
    hspeed = 3;
    }

    if(keyboard_check(vk_left) && place_free(x-1,y)) {
    hspeed = -3;
    }

    if(!keyboard_check(vk_left) && !keyboard_check(vk_right)) {
    platform_friction(true, 1);
    } else {

    platform_friction(false, 1);
   }

   if (keyboard_check(vk_up) && !place_free(x,y+1) && place_free(x,y-1)) {
   vspeed = -7;
   }
}
 
Last edited by a moderator:

Alexx

Member
Are you using this:
create;
create: global.points=0;

In more than one place?

Also any reason you are using:
Code:
global.points
rather than just:
Code:
score
?
 
J

Januxor

Guest
Are you using this:
create;
create: global.points=0;

In more than one place?

Also any reason you are using:
Code:
global.points
rather than just:
Code:
score
?
ok I change everything to global.score I was using global.points cause it was like that in one vid but its still the same when I change the room and yes I am using global.points (score) in more than one places? is that a problem?
 

RangerX

Member
If you save your score in the global, you don't lose it by changing rooms.
If it becomes zero again after you changed room, this means there's an object that did put it back to zero.
You're bound to find somewhere where the engine reads: global.points=0;
 

Alexx

Member
is that a problem?
No, it is not a problem, would just use score as it already has global reach, hence you can use score instead of global.score.
score also defaults with a value of 0, though I'd advise setting to 0 once at the start of your game.
 
Last edited:
J

Januxor

Guest
If you save your score in the global, you don't lose it by changing rooms.
If it becomes zero again after you changed room, this means there's an object that did put it back to zero.
You're bound to find somewhere where the engine reads: global.points=0;
so it cant be on create event?
So what to put in create event?

edit: nvm its fixed
 
Last edited by a moderator:
J

Januxor

Guest
thank you guys alot! so yea global.points = 0; will change it back to 0 so I change it to score like alexx said and I puted += like:
Code:
score += 0;
in create event so its relative!
:)
 

Alexx

Member
I think you misunderstood the point I was trying to make, but at-least it is working for you.
 
Top