anyone wanna make an UGH! remake?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post 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
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post 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?
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post 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
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post 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.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post 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.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post 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
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post by PixelP »

Should I completly delete the input function?
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post by avansc »

PixelP wrote:Should I completly delete the input function?

yes. we will handel that seperatly
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post 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;
}
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post by PixelP »

Okey.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: anyone wanna make an UGH! remake?

Post 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
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: anyone wanna make an UGH! remake?

Post 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;
}
Post Reply