Page 3 of 6

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 7:02 pm
by PixelP
integers: x, y, w, h, xvel, yvel
booleans: flying, got_passeneger
??
I downloaded this game for like an hour ago... I haven't played so much

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 7:49 pm
by avansc
good. those are all good values. no make a class with some functions to make a player, to change variables and so on. and post the class.
next we will tackle making a physics class what will update motion and detect collision.

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 8:04 pm
by PixelP
What width and height will the player have, what fps are we using and what's the width and height for our game window?

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 8:14 pm
by avansc
PixelP wrote:What width and height will the player have and what fps are we using?

you can make the width and heigth whatever you want. dont worry about FPS now. we will regulate that later.

let plan on making the level 500 X 500 pixels and the player it 20X20

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 8:20 pm
by PixelP
Okey, I used 60 as fps for now...

Code: Select all

//timer.h
#pragma once

class TimerClass {
    private:
        int start;

    public:
        void Begin();
        int Get();
};

void TimerClass::Begin() {
    start = SDL_GetTicks();
}

int TimerClass::Get() {
    return SDL_GetTicks() - start;
}
Timer class... I'm working on the player class.

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 8:25 pm
by avansc
dont worry about a times class right now. that can come later.

work on the player class. then we will make a physics class that takes a level class and player class and makes sure the player does not gow through objects.

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 8:55 pm
by PixelP

Code: Select all

//player.h
#pragma once

#include "functions.h"

void draw_image(SDL_Surface* image, SDL_Surface* buffer, int x, int y, SDL_Rect* clip) {
	SDL_Rect offset = {x, y};
	SDL_BlitSurface(image, clip, buffer, &offset);
}

class PlayerClass {
    public:
        SDL_Rect pla;
        int xvel, yvel;
        int fall_speed;
        int speed;

        PlayerClass();
        void get_input();
        void move();
        void draw();
};

PlayerClass::PlayerClass() {
    pla.x = 0;
    pla.y = 0;
    pla.w = 20;
    pla.h = 20;
    xvel = yvel = 0;
    fall_speed = 5;
    speed = 10;
}

void PlayerClass::get_input() {
    if(key[SDLK_UP]) {
        yvel -= speed;
    } if(key[SDLK_RIGHT]) {
        xvel += speed;
    } if(key[SDLK_DOWN]) {
        yvel += speed;
    } if(key[SDLK_LEFT]) {
        xvel -= speed;
    }

    if(!key[SDLK_UP]) {
        yvel += speed;
    } if(!key[SDLK_RIGHT]) {
        xvel -= speed;
    } if(!key[SDLK_DOWN]) {
        yvel -= speed;
    } if(!key[SDLK_LEFT]) {
        xvel += speed;
    }
}

void PlayerClass::move() {
    pla.x = xvel;
    pla.y = yvel;
}

void PlayerClass::draw() {
    draw_image(player_img, buffer, pla.x, pla.y, NULL);
}
That's the player class so far.

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:00 pm
by avansc
hange the input thing, becaus the way you have it requiers key to be global. we will do it differently.
also, dont use fall speed, use weight, and the physics class will do the calculations for us.

make those changes and start working on a physics class.

you just want a funtion that return bool if a player position is in a object position

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:04 pm
by PixelP
Should I completly delete the input function?

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:08 pm
by avansc
PixelP wrote:Should I completly delete the input function?

yes. we will handel that seperatly

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:12 pm
by PixelP

Code: Select all

//physic.h
#pragma once

class PhysicClass {
    public:
        bool collision(PlayerClass* pla, ObjectClass* obj);
};

bool collision(PlayerClass* pla, ObjectClass* obj) {
    if(pla->w > obj->x && pla->h > obj->y && pla->x < obj->w && pla->y < obj->h) {
        return true;
    }

    return false;
}

Code: Select all

void PlayerClass::move() {
    x = xvel;
    yvel+=weight;
    y = yvel;
}

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:15 pm
by avansc
no, dont put any calculations in the player class. just functions that can chage values and what not. the physics stuff we will put into physics class.

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:16 pm
by PixelP
Okey.

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:18 pm
by avansc
PixelP wrote:Okey.

have you made a physics class yet?

there will be

update_player
collision //check to see if there are any collisions between the player and any of the objects

Re: anyone wanna make an UGH! remake?

Posted: Fri Dec 05, 2008 9:22 pm
by PixelP

Code: Select all

//physic.h
#pragma once

class PhysicClass {
    public:
        bool collision(PlayerClass* pla, ObjectClass* obj);
};

bool collision(PlayerClass* pla, ObjectClass* obj) {
    if(pla->w > obj->x && pla->h > obj->y && pla->x < obj->w && pla->y < obj->h) {
        return true;
    }

    return false;
}