replaced load_shaders();
Funktion zur Vergroeßerung/Verkleinerung der Map hinzugefuegt; git-svn-id: svn://ammerhai.com/home/mike/pokemon_repo@11 24008968-59e6-ed4c-a10b-0b2c954b24ab
This commit is contained in:
parent
bfae037947
commit
63088db2a9
Binary file not shown.
Binary file not shown.
BIN
bin/pokemon.exe
BIN
bin/pokemon.exe
Binary file not shown.
BIN
bin/pokemon.pdb
BIN
bin/pokemon.pdb
Binary file not shown.
220
src/main.cpp
220
src/main.cpp
@ -109,38 +109,6 @@ Player player = {
|
||||
.pos_y = 6,
|
||||
};
|
||||
|
||||
bool LoadShaders() {
|
||||
|
||||
ID3DBlob* error_msgs = 0;
|
||||
HRESULT error_code = 0;
|
||||
|
||||
if (error_code = D3DCompileFromFile(L"../Assets/Shader/basic_vertex_shader.hlsl", 0, 0, "main", "vs_5_0", D3DCOMPILE_DEBUG | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_SKIP_OPTIMIZATION, 0, &vertex_shader_code, &error_msgs)) {
|
||||
log("CompileFromFile has failed");
|
||||
if (error_msgs)
|
||||
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (device->CreateVertexShader(vertex_shader_code->GetBufferPointer(), vertex_shader_code->GetBufferSize(), 0, &vertex_shader)) {
|
||||
log_error("CreateVertexShader has failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error_code = D3DCompileFromFile(L"../Assets/Shader/basic_pixel_shader.hlsl", 0, 0, "main", "ps_5_0", D3DCOMPILE_DEBUG | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_OPTIMIZATION_LEVEL0, 0, &pixel_shader_code, &error_msgs)) {
|
||||
log("CompileFromFile has failed");
|
||||
if (error_msgs)
|
||||
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (device->CreatePixelShader(pixel_shader_code->GetBufferPointer(), pixel_shader_code->GetBufferSize(), 0, &pixel_shader)) {
|
||||
log_error("CreatePixelShader has failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void save_map() {
|
||||
log("Save file is under construction.");
|
||||
FILE* file = fopen("../assets/map/map.sv", "wb");
|
||||
@ -204,76 +172,160 @@ void change_map_size(char direction, int amount) {
|
||||
auto old_map_width = map_width;
|
||||
auto old_map_height = map_height;
|
||||
|
||||
if (direction == 'W' || direction == 'E') {
|
||||
map_width += amount;
|
||||
}
|
||||
if (direction == 'N' || direction == 'S') {
|
||||
map_height += amount;
|
||||
}
|
||||
map_tiles = (Tile*)malloc(map_width * map_height * sizeof(Tile));
|
||||
|
||||
#if 0
|
||||
switch (direction) {
|
||||
|
||||
case 'W': {
|
||||
map_width += 1;
|
||||
map_tiles = (Tile*)malloc(map_width * map_height * sizeof(Tile));
|
||||
for (int y = 0; y < old_map_height; y++) {
|
||||
for (int x = 0; x < old_map_width; x++) {
|
||||
map_tiles[y * map_width + x + 1] = old_map[y * old_map_width + x];
|
||||
for (int y = 0; y < min(old_map_height, map_height); y++) {
|
||||
for (int x = 0; x < min(old_map_width, map_width); x++) {
|
||||
if (amount < 0) {
|
||||
map_tiles[(y + 0) * map_width + x] = old_map[y * old_map_width + (x - amount)];
|
||||
}
|
||||
else {
|
||||
map_tiles[(y + 0) * map_width + (x + amount)] = old_map[y * old_map_width + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < map_height; y++) {
|
||||
map_tiles[y * map_width + 0].type = 0;
|
||||
for (int x = 0; x < amount; x++) {
|
||||
map_tiles[y * map_width + (x + 0)].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
log("Increased map size: WEST");
|
||||
player.pos_x = player.pos_x + amount;
|
||||
|
||||
log("Changed map size: WEST");
|
||||
} break;
|
||||
|
||||
case 'E': {
|
||||
map_width += 1;
|
||||
map_tiles = (Tile*)malloc(map_width * map_height * sizeof(Tile));
|
||||
for (int y = 0; y < old_map_height; y++) {
|
||||
for (int x = 0; x < old_map_width; x++) {
|
||||
map_tiles[y * map_width + x] = old_map[y * old_map_width + x];
|
||||
for (int y = 0; y < min(old_map_height, map_height); y++) {
|
||||
for (int x = 0; x < min(old_map_width, map_width); x++) {
|
||||
map_tiles[(y + 0) * map_width + (x + 0)] = old_map[y * old_map_width + (x)];
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < map_height; y++) {
|
||||
map_tiles[y * map_width + old_map_width].type = 0;
|
||||
for (int x = 0; x < amount; x++) {
|
||||
map_tiles[y * map_width + (x + old_map_width)].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
log("Increased map size: EAST");
|
||||
log("Changed map size: EAST");
|
||||
} break;
|
||||
|
||||
case 'N': {
|
||||
map_height += 1;
|
||||
map_tiles = (Tile*)malloc(map_width * map_height * sizeof(Tile));
|
||||
for (int y = 0; y < old_map_height; y++) {
|
||||
for (int x = 0; x < old_map_width; x++) {
|
||||
map_tiles[(y + 1) * map_width + x] = old_map[y * old_map_width + x];
|
||||
for (int y = 0; y < min(old_map_height, map_height); y++) {
|
||||
for (int x = 0; x < min(old_map_width, map_width); x++) {
|
||||
if (amount < 0) {
|
||||
map_tiles[y * map_width + (x + 0)] = old_map[(y - amount) * old_map_width + x];
|
||||
}
|
||||
else {
|
||||
map_tiles[(y + amount) * map_width + (x + 0)] = old_map[y * old_map_width + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < map_width; x++) {
|
||||
map_tiles[0 * map_width + x].type = 0;
|
||||
for (int y = 0; y < amount; y++) {
|
||||
for (int x = 0; x < map_width; x++) {
|
||||
map_tiles[(y + 0) * map_width + x].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
log("Increased map size: NORTH");
|
||||
player.pos_y = player.pos_y + amount;
|
||||
|
||||
log("Changed map size: NORTH");
|
||||
} break;
|
||||
|
||||
case 'S': {
|
||||
map_height += 1;
|
||||
map_tiles = (Tile*)malloc(map_width * map_height * sizeof(Tile));
|
||||
for (int y = 0; y < old_map_height; y++) {
|
||||
for (int x = 0; x < old_map_width; x++) {
|
||||
map_tiles[y * map_width + x] = old_map[y * old_map_width + x];
|
||||
for (int y = 0; y < min(old_map_height, map_height); y++) {
|
||||
for (int x = 0; x < min(old_map_width, map_width); x++) {
|
||||
map_tiles[(y + 0) * map_width + (x + 0)] = old_map[y * old_map_width + x];
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < map_width; x++) {
|
||||
map_tiles[old_map_height * map_width + x].type = 0;
|
||||
for (int y = 0; y < amount; y++) {
|
||||
for (int x = 0; x < map_width; x++) {
|
||||
map_tiles[(y + old_map_height) * map_width + x].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
log("Increased map size: SOUTH");
|
||||
}break;
|
||||
log("Changed map size: SOUTH");
|
||||
} break;
|
||||
}
|
||||
#endif
|
||||
for (int y = 0; y < min(old_map_height, map_height); y++) {
|
||||
for (int x = 0; x < min(old_map_width, map_width); x++) {
|
||||
if (direction == 'W') {
|
||||
if (amount < 0) {
|
||||
map_tiles[(y + 0) * map_width + x] = old_map[y * old_map_width + (x - amount)];
|
||||
}
|
||||
else {
|
||||
map_tiles[(y + 0) * map_width + (x + amount)] = old_map[y * old_map_width + x];
|
||||
}
|
||||
}
|
||||
if (direction == 'E') {
|
||||
map_tiles[(y + 0) * map_width + (x + 0)] = old_map[y * old_map_width + (x)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int y = 0; y < map_height; y++) {
|
||||
for (int x = 0; x < amount; x++) {
|
||||
if (direction == 'W')
|
||||
map_tiles[y * map_width + (x + 0)].type = 0;
|
||||
if (direction == 'E')
|
||||
map_tiles[y * map_width + (x + old_map_width)].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (direction == 'W')
|
||||
player.pos_x = player.pos_x + amount;
|
||||
|
||||
for (int y = 0; y < min(old_map_height, map_height); y++) {
|
||||
for (int x = 0; x < min(old_map_width, map_width); x++) {
|
||||
if (direction == 'N') {
|
||||
if (amount < 0) {
|
||||
map_tiles[y * map_width + (x + 0)] = old_map[(y - amount) * old_map_width + x];
|
||||
}
|
||||
else {
|
||||
map_tiles[(y + amount) * map_width + (x + 0)] = old_map[y * old_map_width + x];
|
||||
}
|
||||
}
|
||||
if (direction == 'S') {
|
||||
map_tiles[(y + 0) * map_width + (x + 0)] = old_map[y * old_map_width + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < amount; y++) {
|
||||
for (int x = 0; x < map_width; x++) {
|
||||
if(direction == 'N')
|
||||
map_tiles[(y + 0) * map_width + x].type = 0;
|
||||
if(direction == 'S')
|
||||
map_tiles[(y + old_map_height) * map_width + x].type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (direction == 'N')
|
||||
player.pos_y = player.pos_y + amount;
|
||||
|
||||
player.pos_x = clamp(0, player.pos_x, map_width - 1);
|
||||
player.pos_y = clamp(0, player.pos_y, map_height - 1);
|
||||
|
||||
free(old_map);
|
||||
}
|
||||
|
||||
|
||||
//Userinputs, Steuerung, FensterÄnderungen -> WindowProc
|
||||
LRESULT WindowMsgs(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam) {
|
||||
LRESULT Result = 0;
|
||||
|
||||
@ -315,28 +367,28 @@ LRESULT WindowMsgs(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam) {
|
||||
if(wParam & MK_CONTROL)
|
||||
change_map_size('W', -1);
|
||||
else
|
||||
change_map_size('W', 1);
|
||||
change_map_size('W', 2);
|
||||
}
|
||||
|
||||
if (wParam & MK_SHIFT && tile_x == map_width) {
|
||||
if (wParam & MK_CONTROL)
|
||||
change_map_size('E', -1);
|
||||
else
|
||||
change_map_size('E', 1);
|
||||
change_map_size('E', 2);
|
||||
}
|
||||
|
||||
if (wParam & MK_SHIFT && tile_y == -1) {
|
||||
if (wParam & MK_CONTROL)
|
||||
change_map_size('N', -1);
|
||||
else
|
||||
change_map_size('N', 1);
|
||||
change_map_size('N', 2);
|
||||
}
|
||||
|
||||
if (wParam & MK_SHIFT && tile_y == map_height) {
|
||||
if (wParam & MK_CONTROL)
|
||||
change_map_size('S', -1);
|
||||
else
|
||||
change_map_size('S', 1);
|
||||
change_map_size('S', 2);
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -411,6 +463,38 @@ ID3D11Buffer* CreateBuffer(String name, uint32 num_bytes, void* data = 0, uint32
|
||||
}
|
||||
|
||||
|
||||
bool LoadShaders() {
|
||||
|
||||
ID3DBlob* error_msgs = 0;
|
||||
HRESULT error_code = 0;
|
||||
|
||||
if (error_code = D3DCompileFromFile(L"../Assets/Shader/basic_vertex_shader.hlsl", 0, 0, "main", "vs_5_0", D3DCOMPILE_DEBUG | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_SKIP_OPTIMIZATION, 0, &vertex_shader_code, &error_msgs)) {
|
||||
log("CompileFromFile has failed");
|
||||
if (error_msgs)
|
||||
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (device->CreateVertexShader(vertex_shader_code->GetBufferPointer(), vertex_shader_code->GetBufferSize(), 0, &vertex_shader)) {
|
||||
log_error("CreateVertexShader has failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error_code = D3DCompileFromFile(L"../Assets/Shader/basic_pixel_shader.hlsl", 0, 0, "main", "ps_5_0", D3DCOMPILE_DEBUG | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_OPTIMIZATION_LEVEL0, 0, &pixel_shader_code, &error_msgs)) {
|
||||
log("CompileFromFile has failed");
|
||||
if (error_msgs)
|
||||
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (device->CreatePixelShader(pixel_shader_code->GetBufferPointer(), pixel_shader_code->GetBufferSize(), 0, &pixel_shader)) {
|
||||
log_error("CreatePixelShader has failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool init_directx11(HWND Window) {
|
||||
D3D_FEATURE_LEVEL feature_levels[] = { D3D_FEATURE_LEVEL_11_0 };
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user