pseudocode

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.8 kB
1
Indexable


______________________________________________________________________
main.cpp



#include <iostream>
#include player.cpp
#include math.cpp

int inj() {
    //... int *playercount = static_cast<int*>(...)
    Player playerlist[MAX_PLAYERS];
    while (true){
        Player *player = NULL; // if not reassigned, skip
        for (int i = 0; i < *playercount; i++)
        {
            //.. SIZE* player_list = (SIZE*)(...)
            Player *player = playerlist + i*4 // 4 size of one player
            if (player != NULL){
                
            }
        }

        for (Player player: playerlist)
        {
            
        }
    }
}

_______________________________________________________________________________
player.cpp

#include math.cpp
#define MAX_PLAYERS ___

class Player
{
    public:
    //...
    
    //... vec3 origin(x, y, z);
}

_______________________________________________________________________________
math.cpp

class vec3
{
    public:
        float x, y, z;
        vec3(float x=0.0f, float y=0.0f, float z=0.0f);
    
    vec3 operator-(vec3 &vec)
    {
        return (vec.x - x, vec.y - y, vec.z - z);
    }
    
    vec3 operator+(vec3 &vec)
    {
        return (vec.x + x, vec.y + y, vec.z + z);
    }
}

bool toScreen(vec3& obj, vec3 &camera)
{
    //.. int centerwidth = width/2;
    //.. int centerheight = height/2;
    
    float relativeX = obj.x - camera.x; 
    float relativeY = obj.x - camera.x;
    
    float scaledX = relativeX / (obj.z - camera.z);
    float scaledY = relativeY / (obj.z - camera.z);
    
    int screenX = scaledX + centerwidth;
    int screenY = scaledY + centerheight;
    
    return screenX, screenY;
}

______________________________________________________________________________







Leave a Comment