• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By RidiculousName
      I've made a very simple map generator as a demo for combat encounters in my game. I plan to have the trees and rocks be cover, while the player's bandits ambush a caravan on the road in the middle. Please, let me know what you think. Criticism is welcome.
      """ Generates a basic map for combat """ __Author__ = "RidiculousName" __date__ = "3/21/18" import pygame as pg import copy import random def createMap(width, height, trees, rocks, roadWidth): """ creates a combat map :param width: int; 20-60 width of map in squares :param height: int; 20-60 height of map in squares :param trees: int; 0 to (width*height)//5 # of trees in map :param rocks: int; 0 to (width*height)//5 # of rocks in map :param roadWidth: int; 0-10 width of road in map (if value=0, will not have a road) :return: tuple matrix of map """ # variable declarations mapMatrix = [] rowList = [0] * width treeLocations = [] rockLocations = [] colIndex = random.randint(0, height) rowIndex = random.randint(0, width) #error checking if trees > (width * height) // 3: print("ERROR: TOO MANY TREES") return 0 elif rocks > (width * height) // 3: print("ERROR: TOO MANY ROCKS") return 0 # create a blank map full of grass for i in range(height): row = copy.copy(rowList) mapMatrix.append(row) # add trees for i in range(trees): while (rowIndex, colIndex) in treeLocations: colIndex = random.randint(0, height - 1) rowIndex = random.randint(0, width - 1) mapMatrix[rowIndex][colIndex] = 1 treeLocations.append((rowIndex, colIndex)) # add rocks for i in range(rocks): while (rowIndex, colIndex) in treeLocations \ or (rowIndex, colIndex) in rockLocations: colIndex = random.randint(0, height - 1) rowIndex = random.randint(0, width - 1) mapMatrix[rowIndex][colIndex] = 2 rockLocations.append((rowIndex, colIndex)) # add the road if roadWidth > 0: ct = int(roadWidth // 2) road = int(height // 2) while ct > 0: mapMatrix[road + ct] = [3] * width mapMatrix[road - ct] = [3] * width ct -= 1 mapMatrix[road] = [3] * width # convert to tuple for i in range(height): mapMatrix[i] = tuple(mapMatrix[i]) # return return tuple(mapMatrix) def showMap(screen, mapMatrix): """ :param screen: pygame screen object images are blitted to this :param mapMatrix: list matrix contains the map matrix :return: none """ # variable declarations height = pg.display.Info().current_h width = pg.display.Info().current_w x_pos = 0 y_pos = 0 grass = pg.image.load("grass.png").convert() tree = pg.image.load("tree.png").convert() rock = pg.image.load("rock.png").convert() road = pg.image.load("road.png").convert() for i in range(len(mapMatrix)): for j in range(len(mapMatrix[i])): if mapMatrix[i][j] == 0: screen.blit(grass, [x_pos, y_pos]) elif mapMatrix[i][j] == 1: screen.blit(tree, [x_pos, y_pos]) elif mapMatrix[i][j] == 2: screen.blit(rock, [x_pos, y_pos]) elif mapMatrix[i][j] == 3: screen.blit(road, [x_pos, y_pos]) x_pos += 16 y_pos += 16 x_pos = 0 def main(): """ calls functions to allow the game to run """ # variable declarations done = False # initialize pygame pg.init() # make screen object size = (1600, 900) screen = pg.display.set_mode(size) # set window caption pg.display.set_caption("Bandit King") #manages FPS clock = pg.time.Clock() #creates map mapMatrix = createMap(30, 30, 140, 20, 2) while not done: # --- main event loop for event in pg.event.get(): if event.type == pg.QUIT: done = True # --- game logic # --- drawing code showMap(screen, mapMatrix) # --- update screen pg.display.flip() # --- limit to 60 FPS clock.tick(60) #print("height: ", pg.display.Info().current_h, "width: ", pg.display.Info().current_w) pg.quit() if __name__ == "__main__": main()
    • By TVD
      Hello! I've been making 2d Game Art in my spare time as a hobby for a long long while now but I hope to do something with it, hoping my material is good enough. Below I've attached some random mockups I've made to make an impression of my visual style.
      I wish to see if there's any opportunities- if anyone sees potential and perhaps developers/programmers want to work together to make something happen.
      Feel free to leave any feedback or thoughts if you want to work together on anything here, or you can email me at tvd.art.contact@gmail.com

    • By EddieK
      Hello everyone, I want present my new game which I've been working on for a quite while now.
      It's a 2D zombie shooter with lots of cool weapons to choose from. Kill zombies, level up, buy new weapons and go through different levels. 
      Google Play Store link: https://play.google.com/store/apps/details?id=com.extrabitgames.killerjack&hl=en

      Any feedback is appreciated  
    • By MountainGoblin
      Hi everyone!

      Let me represent my first game.

      It's mix of arcade and logic (just a little).

      Play Market:

      Spiteful UFOs seized the hedgehog commune. Four hedgehog fighting commandos will not give them any chance to destroy it.
      Be the fifth member of the team. 
      Destroy alien’s bases!
      Save your friends!
      Use the commandos’ features to seize and destroy aliens’ bases. 
      You won’t be able to clean the commune from hateful aliens without rationality, speed and agility. 
      - 40 fascinating levels in different parts of the world;
      - 8 different locations.
      I'll wait for yours feedback. It's very important for upcomming updates!

    • By elect
      ok, so, we are having problems with our current mirror reflection implementation.
      At the moment we are doing it very simple, so for the i-th frame, we calculate the reflection vectors given the viewPoint and some predefined points on the mirror surface (position and normal).
      Then, using the least squared algorithm, we find the point that has the minimum distance from all these reflections vectors. This is going to be our virtual viewPoint (with the right orientation).
      After that, we render offscreen to a texture by setting the OpenGL camera on the virtual viewPoint.
      And finally we use the rendered texture on the mirror surface.
      So far this has always been fine, but now we are having some more strong constraints on accuracy.
      What are our best options given that:
      - we have a dynamic scene, the mirror and parts of the scene can change continuously from frame to frame
      - we have about 3k points (with normals) per mirror, calculated offline using some cad program (such as Catia)
      - all the mirror are always perfectly spherical (with different radius vertically and horizontally) and they are always convex
      - a scene can have up to 10 mirror
      - it should be fast enough also for vr (Htc Vive) on fastest gpus (only desktops)

      Looking around, some papers talk about calculating some caustic surface derivation offline, but I don't know if this suits my case
      Also, another paper, used some acceleration structures to detect the intersection between the reflection vectors and the scene, and then adjust the corresponding texture coordinate. This looks the most accurate but also very heavy from a computational point of view.

      Other than that, I couldn't find anything updated/exhaustive around, can you help me?
      Thanks in advance
  • Advertisement
  • Advertisement
Sign in to follow this  

OpenGL [Solved] SDL_GL_SwapWindow seems It doesn't work for me

Recommended Posts

Hi there, 

I posted this to be resolved in SDL forums so Im gonna left here the link to original discussion https://discourse.libsdl.org/t/sdl-gl-swapwindow-is-not-working-for-me/22863

I don't want duplicate posts but I want reach the most people I be able to.


Tell me If you think this is bad habits so I won't do again in advance.



Edited by vonflaken
Issue resolved

Share this post

Link to post
Share on other sites

Please don't just link some other post. Include the actual problem you're having here, as well. If somebody has to go read some other forum thread to find out what the problem is, that decreases their likelihood of bothering to try to help you. It also means if the URL changes or the other site goes down, this thread is useless.

Share this post

Link to post
Share on other sites

Mhhh yhea, appreciate the suggestion and I think you are right, I will follow this rule from now.

Anyway I resolved the problem, I summary here quickly:

I use OpenGL and SDL in the project, my render-loop seems to be working nice but nothing drawn in screen. I debug in RenderDoc and I see sprites blitz in frame buffer so I though the issue was something around buffers no swapping for some reason. At the end, I debugged OpenGL code with glGetError and I catch an error in my code (I generated VAO with glGenBuffers instead of glGenVertexArrays). Now is working nicely.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement