Jump to content
  • Advertisement

Swiss Cheese

  • Content Count

  • Joined

  • Last visited

Community Reputation

106 Neutral

About Swiss Cheese

  • Rank

Personal Information

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Swiss Cheese

    Path Calculation

    Thank you Guys, I've found a solution here https://www.youtube.com/watch?v=KiCBXu4P-2Y
  2. Swiss Cheese

    Path Calculation

    I did something like this. but I need to find out the shortest path without walking into all the dead ends or walking back. but sometimes I have to walk back if I get the wrong way. I need something like a algorythm scheme. Thanks, will check it out 😀
  3. Hi Volks I'm stuck since weeks with my Gameproject because the Path Calculation. (programming in C) The Game is 4096x4096 divided by tiles of 64x64. How can I find the shortest Path from green point to red point (attachment Image)
  4. Swiss Cheese

    SDL2 Preparing Background with Tiles Surface is empty

    Thank you very much. I wrote this line and it works. SDL_Surface *bg_surface = SDL_CreateRGBSurface(0,1024,1024,32,0,0,0,0); I do error handling now. It was only a test. :D
  5. Hello Guys I need help. I want to prepare a Surface with Background tiles once. Because I dont want to write all the tiles on every gameloop.  It would waste cpu. My Idea is, to create a Surface with static tiles and copying this surface inside the gameloop to the texture memory and then paint all the additional graphics and sprites. In my test I got a black screen without the tile background. No Compile error. What I'm doing wrong? #include "SDL2/SDL.h" #include "SDL2/SDL_timer.h" #include "SDL2/SDL_image.h" #include <stdio.h> #include <stdbool.h> /* gcc bgtiles_test.c -o bgtiles_test.exe -lmingw32 -lSDL2main -lSDL2 -lSDL2_image */ int main( int argc, char *args[] ) { SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER); SDL_Window *win = SDL_CreateWindow("B_Game 0.001", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280,720,0); //Uint32 render_flags = SDL_RENDERER_ACCELERATED; SDL_Renderer *rend = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED); SDL_Surface *bg_tile = SDL_LoadBMP("assets/tiles/water.bmp"); SDL_Surface *bg_surface = NULL; SDL_Rect size_bg_tile = {0,0,64,64}; SDL_Rect coord = {0, 0, 64, 64}; const Uint8 *keys = SDL_GetKeyboardState(NULL); SDL_Event e; bool quit = false; int x = 0; int y = 0; //fill surface 1024x1024 with background tiles 64x64 for(y=0;y<1024;y+=64){ for(x=0;x<1024;x+=64){ coord.x = x; coord.y = y; //blitting bg tiles into bg_surface SDL_BlitSurface(bg_tile, &size_bg_tile, bg_surface, &coord); } } //copy bg_surface to gfx memory SDL_Texture *text_bg_surface = SDL_CreateTextureFromSurface(rend, bg_surface); while(!quit){ while (SDL_PollEvent(&e)){ if (keys[SDL_SCANCODE_A]){ quit = true; } } SDL_RenderClear(rend); SDL_RenderCopy(rend, text_bg_surface, NULL, NULL); /* add additional graphics later */ SDL_RenderPresent(rend); SDL_Delay(5); } SDL_FreeSurface(bg_tile); SDL_FreeSurface(bg_surface); SDL_DestroyTexture(text_bg_surface); SDL_DestroyRenderer(rend); SDL_DestroyWindow(win); SDL_Quit(); return 0; }
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!