_id
int64
0
49
text
stringlengths
71
4.19k
19
Why do I get a segmentation fault on launch with this code? I am currently writing a pong clone in C with SDL on top. Currently, I have hit a roadblock. If I add a new variable, my game won't launch, and will give "segmentation fault" in the debug terminal. When I comment out a variable, the following code gives no errors, but otherwise, it just returns "Segmentation Fault" on the debug terminal after flashing the frame the game would normally appear in. ifdef cplusplus include lt cstdlib gt else include lt stdlib.h gt endif ifdef APPLE include lt SDL SDL.h gt else include lt SDL.h gt endif include "SDL SDL image.h" include "SDL SDL framerate.h" include "checkcol.h" Uint8 keystates SDL GetKeyState( NULL ) int main ( int argc, char argv ) initialize SDL video if ( SDL Init( SDL INIT EVERYTHING ) lt 0 ) printf( "Unable to init SDL s n", SDL GetError() ) return 1 atexit(SDL Quit) make sure SDL cleans up before exit create a new window SDL Surface screen SDL SetVideoMode(640, 480, 16,SDL HWSURFACE SDL DOUBLEBUF) if ( !screen ) printf("Unable to set 640x480 video s n", SDL GetError()) return 1 SDL Surface left IMG Load("left.png") SDL Surface right IMG Load("right.png") SDL Surface ball IMG Load("ball.png") if (!left !right !ball) printf("Unable to load a png s n", SDL GetError()) return 1 centre the bitmap on screen SDL Rect leftr leftr.x 0 leftr.y (screen gt h left gt h) 2 SDL Rect rightr rightr.x (screen gt w right gt w) rightr.y (screen gt h right gt h) 2 SDL Rect ball1 ball1.x ((screen gt w ball gt w) 2) 50 ball1.y (screen gt h ball gt h) 2 SDL Rect ball2 ball2.x ((screen gt w ball gt w) 2) 50 ball2.y (screen gt h ball gt h) 2 bool b1xm 0 describes ball 1's movement in x bool b1ym 0 bool b2xm 1 bool b2ym 1 unsigned short lscore 0 unsigned short rscore 0 FPSmanager manex SDL initFramerate( manex ) you want the top framerate to be 60 for example SDL setFramerate( manex, 60 ) program main loop bool done false while (!done) this is where my main code is end main loop free loaded images SDL FreeSurface(left) SDL FreeSurface(right) SDL FreeSurface(ball) all is well printf("Exited cleanly n") return 0
19
Are SDL games trivially portable from Linux to Windows? I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of ifdefs to port it or will the very same code work on Windows and Linux? Or is it more complicated? Sorry if these are silly questions. I couldn't find existing resources on porting SDL games between desktop systems and I've never done this before!
19
Multiple keypresses causing wierd results in SDL I have been building a pong clone. I've been using a mixture of peoples different code to understand the way they structure their games as well as reading on game patterns. Currently I've gotten to draw a paddle on the screen and the player can move it with the keyboard no problem. The issue comes when a player presses a button that is not 'Up' or 'Down'. For instance when the player holds the 'Up' key the paddle travels upwards, but if they simultaneously hold the 'Right' key it causes the paddle to fly downwards at a much greater speed. My keyboard checking code is void GameLoop Input(SDL Event amp ev) if (ev.type SDL KEYDOWN) if (ev.key.keysym.scancode SDL SCANCODE DOWN) player1 gt IsMoving(true) player1 gt velocity 10 if (ev.key.keysym.scancode SDL SCANCODE UP) player1 gt IsMoving(true) player1 gt velocity 10 else if (ev.type SDL KEYUP) if (ev.key.keysym.scancode SDL SCANCODE DOWN) player1 gt IsMoving(false) player1 gt velocity 0 if (ev.key.keysym.scancode SDL SCANCODE UP) player1 gt IsMoving(false) player1 gt velocity 0 The GameLoop is ran within loop that is configured to run at 60FPS. You can see this in this code block here int main(int argc, char argv) Initialise the app and SDL App app(SDL INIT VIDEO) GameLoop game double lastTime 0.0, currentTime SDL Event e while (app.isRunning()) if (SDL PollEvent( amp e)) if (e.type SDL QUIT) app.exit() currentTime SDL GetTicks() 1000.0 if (currentTime gt lastTime 0.01666667) game.Input(e) game.Update() game.Render() lastTime currentTime return 0 This is the paddles update code void Paddle Update() if(moving true) rect.y velocity velocity 50 X rect.x Y rect.y I'm unsure of what is causing the paddle to behave so strangely. Any insight given into this problem or even just the way I've approached this problem would be appreciated.
19
SDL PollEvent very slow on SDL2, but works fine on SDL1.2 I have this simple app that displays a screen and handles the quit event while( SDL PollEvent( amp e ) ! 0 ) User requests quit if( e.type SDL QUIT ) quit true If I compile this with SDL1.2 it runs fine, the quit event is handled immediately. However if I compile it for SDL2, then it takes 5 seconds to get that event. And not just quit, but other events also, like mouse. With sdl2 it takes 95 of the cpu, while with sdl1.2 it's 30 40 . The cpu is dual core, 1.2 ghz (pandaboard). I suspect something, but I'm not 100 sure I'm running this on ubuntu 12.04 which natively supports only sdl1.2. So I had to compile sdl2 from source code, as it's not available in that ubuntu. Could this be the reason? Or any other clues what might be wrong? Thanks!
19
SDL Surface clipping mask I am creating a GUI for my game, so I use some buttons like . So you can see it is only text surrounded by a rectangle. But I currently use a huge png image with all the buttons I need arranged as I want it, it is really inefficient, so how can I upload a single smaller image of the rectangle, a sample of the gradient I want and use SDL tff to create a surface. Say I copy the rectangle and the text in an SDL Surface, it should have two colors (black and white), now make white pixel transparent and black pixels to be replaced with the gradient to create the buttons and place them using SDL Rects.
19
Where can I get correct pitch parameter for SDL RenderReadPixels function in SDL2? I have a texture created with SDL TEXTUREACCESS TARGET access and I want to get all its pixels with SDL RenderReadPixels() function. One of the function parameters is pitch and I don't really know where can I can get it. Texture is created with dimensions of a previously created surface, but function call with surface gt pitch as pitch parameter generates EXC BAD ACCESS. Texture and surface dimensions are 800x600, and surface gt pitch returns 3200, which is strange for me, because I thought that pitch is the width of the texture in memory and expected surface gt pitch to be something like 1024.
19
What is missing from SDL for it to gain more widespread adoption? As I understand, SDL offers abstractions that let you make windows, handle input and audio much easier than doing so directly with the low level APIs provided by several operating systems. However, it seems that a lot of games, both indie and AAA, don't use it, and I would like to know why. This makes me suspect that there may be areas where SDL is lacking, such as features, performance, or robustness, when compared to platform specific APIs. Apart from platform support, that is, considering only the platforms SDL supports, I do not understand what would keep a developer from using SDL for their game, since I feel like, based on my admittedly limited knowledge, it'd be much smarter to use SDL on the platforms that do support it.
19
State machine in C for SDL game I want to create a state machine for menu in my SDL game. So this is my code without the SDL I just want to ask if this is a good way to create it. here is a code include lt stdio.h gt include lt windows.h gt enum states Menu, Game, Game over, Exit int main() int game is running 1 enum states state Menu while(game is running 1) switch(state) case Menu state Game printf( quot menu screen with play and exit button. n quot ) need to add if exit or play is pressed if exit then exit program if play than you know... break case Game state Game over printf( quot after play button is pressed game screen will show up. n quot ) after this i will come back to menu. break case Game over state Exit printf( quot screen after game. n quot ) break case Exit printf( quot turn game off. n quot ) this will be in the if function with a game. game is running 0 break Sleep(1000) sleep for a second just for test return 0
19
Is there a way to duplicate the windows desktop zooming in SDL to make low res pixels look like stylyzed cartoon art? When you hit the Win key and numpad plus key at the same time it opens the desktop magnifying glass and the effect of this on low res pixel art is to make it look like super cool stylized cartoon art. I want the game to look like this all the time. Is there a way to do this permanent i SDL or DirectX or OpenGL? How I have achieved this image is to run the game in a small windows and have the windows 10 magnifying glass hoover over it and I hit print screen. And I want the game to look like this all the time in full screen. Ps. This is the Gradius 3 ship that I use for place holder graphics for question asking purposes.
19
Polling events with SDL results in stuttering response when dealing with multiple objects I'm new to SDL programming and I'm not quite sure I got how it handles events. Given an instance like this defined in quot game.c quot static struct SDL Window window SDL Renderer renderer BinaryTree objects game NULL, NULL, NULL (Which of course gets properly initialized) My game loop is defined in the same file as follows void game run() bool closeRequested false while(closeRequested false) SDL RenderClear(game.renderer) binaryTree startIteration(game.objects) while(binaryTree hasNext(game.objects)) GameObject gameObject (GameObject ) binaryTree getNext(game.objects) SDL Event event while(SDL PollEvent( amp event)) if(event.type SDL QUIT) closeRequested true else if(event.type SDL KEYDOWN) gameObject onKeyPressed(gameObject) if(event.key.keysym.scancode SDL SCANCODE UP) gameObject onUpKeyPressed(gameObject) if(event.key.keysym.scancode SDL SCANCODE DOWN) gameObject onDownKeyPressed(gameObject) if(event.key.keysym.scancode SDL SCANCODE LEFT) gameObject onLeftKeyPressed(gameObject) if(event.key.keysym.scancode SDL SCANCODE RIGHT) gameObject onRightKeyPressed(gameObject) if(event.type SDL KEYUP) gameObject onRendering(gameObject) SDL RenderCopy(renderer, gameObject getTexture(gameObject), NULL, gameObject getDestination(gameObject)) SDL RenderPresent(game.renderer) game.objects contains every object which has to be rendered (via game.renderer) onto the the window (game.window). So, on each frame game.objects gets iterated on and for each element various functions get executed, before its texture is loaded to the renderer. Of course gameObject onRightKeyPressed() is called only if the right key was pressed, so if this function is defined as void gameObject onRightKeyPressed(GameObject gameObject) gameObject gt destination.x 1, On each frame that the right key is pressed, gameObject's texture will move by 1 pixel to the right. This works perfectly if game.objects contains only one element, but if a second element gets added, only the first one will smoothly respond to my input, while the other will move by 1 or 2 pixels just once in a while by keeping the right key pressed. It's like the first element contained in game.objects quot steals quot the input, so that when the second element's turn comes, there's no input for it to respond to. What did I do wrong?
19
Memory leak around SDL FreeSurface When I call my tile engine function, the amount of memory my program uses begins to spike at about 80 90 megabytes per second. The memory use continues to go up until the program crashes. The function is below. After tinkering with it, I figured out that I could reduce this bricking to about 15 megabytes per second if I called SDL FreeSurface every time I ran the function. But this confused me, because I thought that you are only supposed to use SDL FreeSurface when the program exits so that the images don't continue to occupy the memory. if I don't call SDL FreeSurface before I blit the tiles, do the previously blitted tiles continue to exist? If I don't how do I fix the aforementioned bug? The edit I made to bring the memory bricking down to 15 megabytes per second is commented out. SDL Surface loadedTile NULL SDL Surface modelIMAGE NULL void enviroment blitTiles(SDL Surface windowENVIRO, int tileAmount, int tileType , int tileXenviro, int tileYenviro, bool quitTiles) HDcounter 1 if(loadedTile ! NULL) SDL FreeSurface(loadedTile) loadedTile IBFobjectENVIRO.loadIMG("tileClipSheet.png") for(int tiles 0 tiles lt tileAmount tiles ) switch(tileType tiles ) Black square (unpassable) case 1 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 0, 0, 75, 75) HDcounter 1 forbiddenX HDcounter tileXenviro 75 forbiddenY HDcounter tileYenviro forbiddenSpriteWidth HDcounter 75 forbiddenSpriteHeight HDcounter 75 forbiddenSpriteDepth HDcounter 75 break Grey square case 2 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 75, 0, 75, 75) break Brown square case 3 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 150, 0, 75, 75) break Invisible square (unpassable) case 4 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 225, 0, 75, 75) HDcounter 1 forbiddenX HDcounter tileXenviro 75 forbiddenY HDcounter tileYenviro forbiddenSpriteWidth HDcounter 75 forbiddenSpriteHeight HDcounter 75 forbiddenSpriteDepth HDcounter 75 break tileXenviro 75 if(tileXenviro gt level1ObjectENVIRO.level1Width) tileYenviro 75 tileXenviro tileXenviro level1ObjectENVIRO.level1Width if(quitTiles true) SDL FreeSurface(loadedTile)
19
Should I cull off screen objects in SDL2 My game will have a large number of objects moving offscreen at any given time, can i just render them all with SDL RenderCopy even though they are off screen or should I only render them if they are on screen? I will probably have many hundreds or throusands of objects loaded at a time. My dev machine is quite overpowered for what I'm trying to do but I am conserned that I just won't notice a preformance drop that may affect players with less powerful computers. So, will checking if each object is on screen before drawing increase performance lower CPU load, or can I safely let SDL handle this with clipping?
19
Background color gradient with SDL I want to create a menu for a game using a color gradient as the background. Is there a way to create a gradient background instead of using an image for it (since I don't know what size the window will be, using an image is no option). Please note I need to achieve this using only the C standard library and the SDL, no other library and no C .
19
What does FPSManager.lastticks stand for in SDL gfx? I'm having trouble finding documentation on SDL gfx, and I can't figure this out. I've managed to use SDL gfx to automatically cap the framerate, and I it's working a lot better than my manual attempt (combining SDL Delay and SDL Getticks). Now I've been trying to learn more about it, and I stumbled onto something. Here's the whole struct typedef struct Uint32 framecount float rateticks Uint32 lastticks Uint32 rate FPSmanager Most variables in this struct are pretty straightforward, but I have no idea of what lastticks stands for. Does anyone know?
19
Why does SDL2 blur pixel art even with SDL HINT RENDER SCALE QUALITY set to 0? I am working on a game with SDL2 and having trouble turning off linear filtering when upscaling textures. My game has a bunch of 32x32 tiles. I used SDL RenderSetLogicalSize so that there is a one to one pixel mapping (i.e. my logical size is n 32 x m 32.) However, when the the whole scene is upscaled to fit the actual screen, it seems to be interpolated (blurry). I saw these two other posts (1, 2) which recommended using SDL SetHint(SDL HINT RENDER SCALE QUALITY, "0") . I did that, but nothing seems to change at all. It returns true and it is in fact changing the hint, but the rendering just doesn't change at all. I even tried setting it with priority but nothing changes. Any idea how to fix this? I am on Windows if that's relavent.
19
Problem getting mouse events while keys held down in SDL2 I'm attempting to write input capturing code using SDL2 on Windows. However, I'm running into a problem. Whenever a key is held down, the SDL event queue has no mouse movement, nor will the mouse move on my screen. Instead, The SDL event queue continually returns the key I am holding down as an SDL KEYDOWN event. Here is a simple example program which reproduces the problem exactly include lt SDL2 SDL.h gt include lt iostream gt int main(int argc, char argv) SDL Init(SDL INIT EVERYTHING) SDL Window window SDL CreateWindow("Moust Input Test", SDL WINDOWPOS UNDEFINED, SDL WINDOWPOS UNDEFINED, 640, 480, SDL WINDOW SHOWN) SDL Event event for( ) while (SDL PollEvent( amp event)) if (event.type SDL QUIT) SDL DestroyWindow(window) return 0 else if (event.type SDL MOUSEMOTION) int x, y SDL GetMouseState( amp x, amp y ) std cout lt lt "Mouse moved to " lt lt x lt lt " " lt lt y lt lt std endl else if (event.type SDL KEYDOWN) std cout lt lt "Code of key pressed " lt lt event.key.keysym.sym lt lt std endl return 0 What I would expect to happen is that, when I hold down a key (for example, 'a'), it prints exactly once Code of key pressed 97 And then, while they key is held down, if the mouse is moved, it prints every time the mouse is moved Mouse moved to wherever Instead, I'll keep seeing over and over again Code of key pressed 97 And I will not get any mouse movement whatsoever on the screen, nor will I get my mouse movement log printed, until I release whatever keys I am holding down. Anybody know how I can capture mouse movement while I have a key held down? The only thing I can think of which could possibly be relevant is I am compiling with MinGW using g Dmain SDL main test.cpp o test.exe L. lib SDL2 lmingw32 lSDL2main lSDL2 mwindows mconsole Thanks. Edit I've also just noticed that the problem persists even when the window is minimized if I am holding a key down in this text window while my program is minimized in another Window, the mouse stops working, though my program is not printing out the key code.
19
How to alter image pixels of a wild life bird? Hello so I was hoping someone knew how to move or change color and position actual image pixels and could explain and show the code to do so. I know how to write pixels on a surface or screen surface usigned int ptr static cast lt unsigned int gt (screen pixels) int offset y (screen gt pitch sizeof(unsigned int)) ptr offset x color But I don't know how to alter or manipulate a image pixel of a png image my thoughts on this was How do I get the values and locations of pixels and what do I have to write to make it happen? Then how do I actually change the values or locations of those gotten pixels and how do I make that happen? any ideas tip suggestions are also welcome! int main(int argc , char argv ) SDL Surface Screen SDL SetVideoMode(640,480,32,SDL SWSURFACE) SDL Surface Image Image IMG Load("image.png") bool done false SDL Event event while(!done) SDL FillRect(Screen,NULL,(0,0,0)) SDL BlitSurface(Image,NULL,Screen,NULL) while(SDL PollEvent( amp event)) switch(event.type) case SDL QUIT return 0 break SDL Flip(Screen) return 0
19
Can I create relative filepaths to images in an XCode SDL project? Can I create relative filepaths to images in an XCode SDL project? I have to use absolute filepaths as it is, but it would be much easier if I could make the filepaths relative.
19
Unable to detect continuous keypress event in SDL I am developing a game using SDL, and am unable to do continuous motion for my object when a key is held down. I'm calling SDL PollEvent() to retrieve all events during a frame, and passing each resulting SDL Event structure into this function void Avatar handle input(SDL Event keyInput) if( keyInput.type SDL KEYDOWN ) Adjust the velocity switch( keyInput.key.keysym.sym ) case SDLK LEFT Move(1) break case SDLK RIGHT Move(2) break The problem is that when I hold down the right or left arrow keys, the avatar only moves once instead of moving continuously for as long as I hold down the key. How can I make the motion continue for as long as the key is held down?
19
How do I access the pixels of an SDL 2 texture? How exactly can one get to the RGBA pixel arrays of SDL 2.0 textures? Does the texture need to be specially initialized and locked down?
19
Is SDL2 alone capable of dynamic (or deferred) lighting? I'm talking about JUST SDL2, not OpenGL or DirectX. Would drawing deferred lighting bulk the CPU up and how would it be done?
19
Background color gradient with SDL I want to create a menu for a game using a color gradient as the background. Is there a way to create a gradient background instead of using an image for it (since I don't know what size the window will be, using an image is no option). Please note I need to achieve this using only the C standard library and the SDL, no other library and no C .
19
Scaling an SDL Surface I want to create a button for a game's UI. The background uses a gradient and then I blit a surface on top of the gradient and use SDL SetColorKey to delete the unwanted pixels. The surfaces are not the same size the clipping mask is 200 x 50 and the gradient 1 x 50, so I need to stretch the gradient to the same width of the cliping mask, I can't use a wider image because the purpose of doing this is to save memory and storage and using the same gradient image on multiple clipping masks of different widths. I found I can use SDL BlitScaled but I need to blit the surface to itself and it appears to be useless because the surface remains the same size, am I doing something wrong? Is there a way to do it without blitting the surface to itself? SDL Rect final size final size.w 200 final size.h 50 final size.x 0 final size.y 0 SDL BlitScaled(gradient surface, NULL, gradient surface, amp final size) do some stuff with those textures SDL CreateTextureFromSurface(renderer, final button surface)
19
Background color gradient with SDL I want to create a menu for a game using a color gradient as the background. Is there a way to create a gradient background instead of using an image for it (since I don't know what size the window will be, using an image is no option). Please note I need to achieve this using only the C standard library and the SDL, no other library and no C .
19
Fast texture pixel access using SDL2 People have asked questions on fast pixel manipulation, but I'm looking to read the RGB color values of each pixel. I've heard of SDL RenderReadPixels but in the docs it says WARNING This is a very slow operation, and should not be used frequently. Is there an SDL2 function that returns an array of all the pixels of a texture or an SDL2 routine that I can use to loop over each pixel?
19
SDL2 for hardware accelerated graphics? I am attempting to make a 3d game using SDL2 just to learn and have a bit of fun. I was wondering if there is any way to get SDL2 do calculations on GPU. I have read that SDL2 Textures uses GPU for calculation, but is there any way to get it to do calculations from my functions using GPU? For example, if I have a function multiplyVectorWithMatrix, and there is a bunch of additions going on in that function, how would I get SDL2 to do those additions using GPU rather than CPU?
19
SDL 1.2 reports wrong screen size I have a multi monitor setup with two displays, both 1920x1200. In games, I can only select resolutions 1920x1200 (like 2560x1200) which makes games unusable. Full screen doesn't work either because it switches one display to 800x600 which means I can't reach the close button... I have to kill the game and then, I have to restore my desktop because all windows are moved resized. How can I force SDL to use any resolution that I want?
19
Why does SDL2 blur pixel art even with SDL HINT RENDER SCALE QUALITY set to 0? I am working on a game with SDL2 and having trouble turning off linear filtering when upscaling textures. My game has a bunch of 32x32 tiles. I used SDL RenderSetLogicalSize so that there is a one to one pixel mapping (i.e. my logical size is n 32 x m 32.) However, when the the whole scene is upscaled to fit the actual screen, it seems to be interpolated (blurry). I saw these two other posts (1, 2) which recommended using SDL SetHint(SDL HINT RENDER SCALE QUALITY, "0") . I did that, but nothing seems to change at all. It returns true and it is in fact changing the hint, but the rendering just doesn't change at all. I even tried setting it with priority but nothing changes. Any idea how to fix this? I am on Windows if that's relavent.
19
Is there a way how to handle multiple SDL PollEvent loops without clearing the event queue? Is there a way how can I handle more SDL PollEvent while loops for one SDL Event, without taking the events off from the event queue? Let us say I have something like this void Game processInput() SDL Event event SDL PollEvent( amp e) Engine InputManager processInput( amp e) GUI Library InputManager processInput( amp e) And then the engine processes the input in function like this void Engine InputManager processInput(SDL Event e) mainEvent e while (SDL PollEvent( amp mainEvent)) switch ( mainEvent.type) case SDL KEYDOWN Engine InputManager pressKey( mainEvent.key.keysym.sym) break case SDL KEYUP Engine InputManager releaseKey( mainEvent.key.keysym.sym) break However, this while loop clears the whole event queue, and another input manager (my GUI, for example) does nothing because it no longer has events in the queue. Is there a possible way to handle this situation?
19
Are SDL games trivially portable from Linux to Windows? I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of ifdefs to port it or will the very same code work on Windows and Linux? Or is it more complicated? Sorry if these are silly questions. I couldn't find existing resources on porting SDL games between desktop systems and I've never done this before!
19
What exactly does SDL RenderSetClipRect do? I assumed that this function would move the area which is clipped out of conceptual space and copied onto the renderer (and subsequently drawn to the window) i.e. change the origin of rendering but it doesn't seem to do this. Anybody know how it works?
19
SDL Multiple keyboard support I am making a game with multiplayer split screen mode using SDL. Basically, I like the idea of having each player plug in his own keyboard to the PC, set custom controls via options and being able to play it with controls that he likes. However, there's a problem. This code gets the keyboard event SDL Event event SDL PollEvent( amp event) SDL Event has member SDL KeyboardEvent key, which has member Uint8 which. In short event.key.which According to this, it should represent keyboard device index, however, I've tried connecting three keyboards to my PC and press the buttons at the same time and the result wasn't satisfying they all had same keyboard indexes. Is there a solution to this? Or am I missing something?
20
Blender modelling for a C game? I want to know if it were possible to integrate models created with Blender into a game written in solely C .
20
frustum culling and exporting a big scene model Let's assume that I created in Blender a race track with landscape. I can export it to single wavefront obj file and then load in my graphics engine using assimp but it doesn't allow to use frustum culling. Should I split such big scene too seperate objects or some model formats allow to split object within single file. How graphics engines load such big scenes ? Do you know some useful techniques articles ?
20
Blender modelling for a C game? I want to know if it were possible to integrate models created with Blender into a game written in solely C .
20
Blender How to unlock transform on bone I was trying to create IK constraint following a Nathan Vegdahl tutorial, and everything was nice and shiny, until i tried to actually move a bone. It's not moving, only rotating. I see that transform lock panel on location is grey and completly locked, and i have no idea what's wrong.
20
Exporting Blender bones' transform matrix I use this simple python script to export bones transformation bones armature.pose.bones for eaach bone in bones SystemMatrix Matrix.Scale( 1, 4, Vector((0, 0, 1))) Matrix.Rotation(radians( 90), 4, 'X') if (bone.parent) Export babylon.write matrix4(file handler, "matrix", bone.parent.matrix.inverted() bone.matrix) else Export babylon.write matrix4(file handler, "matrix", SystemMatrix bone.matrix) I'm using a left handed Y up system but I should forget something about rotation because the result is not correct ( Original (under Blender)
20
Correct way to export from blender to ogre format? When I export from blender to ogre using the blender2ogre add on, I'm not getting anything besides a scene most of the time and when I get a mesh I never get a material. Is there something wrong with my export procedure or what else could I be doing wrong? Update I can export the basic cube from blender to ogre but when I download a model and try to export it I don't get the meshes. Update 2 I tried again and selecting the model in Blender does the difference like the answer here says. I can export an alien and get the mesh and material I rename the files ls workspace DungeonWorld2 assets objects creatures alien Cube.001.mesh Material.002.material Material.005.material Cube.001.mesh.xml Material.003.material Cube.001.skeleton.xml Material.004.material dev dev OptiPlex 745 ls workspace DungeonWorld2 assets objects creatures alien alien.mesh Material.002.material Material.005.material alien.mesh.xml Material.003.material alien.skeleton.xml Material.004.material dev dev OptiPlex 745 But how do I actually load the material since the alien now turns up in the game with no material but it does render the mesh Spatial model3 assetManager .loadModel("objects creatures alien alien.mesh.xml") model3.scale(0.3f, 0.3f, 0.3f) model3.setLocalTranslation( 40.0f, 3.5f, 20.0f) rootNode.attachChild(model3)
20
Blender arm rig not working the way it should I just bought a pair of arms from the unity asset store and imported them into blender, the IK seems to work just fine untill i use a Child of constraint on another bone(which is supposed to be a weapon) on the arm's wrist bone the bone rotates but it wont move. I'll leave a video of it right here, https www.youtube.com watch?v jfLmG2sQ 10 EDIT the wrist bone seems to follow the child WHEN i disconnect the wrists parent, but if i do that the IK doesnt work in general. Appreciate all help, thanks in advance )
20
Why is my model exported from Blender vanishing when using it in UE4 mobile? My 3D models and animation vanishes when I preview it using the mobile view port. However they work just fine for the desktop viewport. I usually model the characters using MakeHuman and import them into Blender. In Blender I animate them and then I import the model animation into UE4. The problem is that my model animation works when I preview it using the shader meant for desktop amp consoles. When I preview my animation using the openGLES2 shader, my model vanishes. Anything I import form belnder vanishes when I view it in a mobile viewport. I cant figure out why this is so? Have any of you experienced this before ? Can you guys let me know how I can correct this issue? Also, if I upload the models from MakeHuman into UE directly, I can upload the files properly in UE. But, when I try the workflow MakeHuman Blender UE with not much modifications to the models in Blender, the models are not visible in the openGLES2 shader. I am not sure why this is happening in Blender and why the models coming out if it is affected. Any help would be appreciated.
20
Blender 2.5 Using a Bezier Circle to set Bezier Curve as the Bevel Object I'm trying to follow the tutorial found here. Around 5 40 (ish) in the video, he adds a Bezier Circle. He then adds the existing Bezier Curve as the Bevel Object on the Circle. This makes the Curve go around the circle creating the 3D chess piece. I'm trying to do the exact same thing, but it's not working. I am using Blender 2.5 however too. When I set my curve to be the Bevel Object of the Circle, my Bezier Circle is just becoming a larger gray disc of goo. I was expecting it to be a 3D chess pawn. You can see a screenshot of what mine looks like Before Bevel Object is Placed After Bevel Object is Placed For the record, the name of my Bezier Curve is "BezierCurve" and the name of my Bezier Circle is "BezierCircle". Thanks in advance, Andy UPDATE 1 I just added a plan unchanged Bezier Curve and unchanged Bezier Circle and performed the same steps and it does work. Something must be wrong with my Bezier Curve in that it isn't being projected correctly around the Circle. UPDATE 2 Just realized that when I set the Bezier Curve handles to "Automatic" using the V shortcut (only for Blender 2.5), then my Circle no longer imitates the 3D curve. I need Automatic I think in order for the Bezier Curve to not be wavy. With Automatic, it does a slight curve directly from point to point. Thoughts?
20
independent lighting per mesh in blender In Blender, is it possible to assign lighting objects effects exclusively to a single mesh? For instance, if I place two meshes next to each other, and two lights (one shining on each mesh), I would want each mesh to not cast a cast any shadow on the other. For example, in the following rendered image from a "test" star system view The rings are casting shadows on the right most planets. I want the rings to only cast shadows on their own planet. Is this possible?
20
Where is the "Scripts Window" menu in Blender 2.59? I'm trying to import a script into Blender, and I have the script in my directory and I pushed F8 to reload scripts, but the instructions for running this script say In the "Scripts Window" run "Scripts Export OGRE Meshes". I've seen other similar instructions for other scripts. But the toolbar only contains "File Add Render Help." Changing the "screen layout" to Scripting doesn't reveal any additional options, either. I'm sure I'm just missing something obvious. Please help!
20
Blender models appear in UDK asset manager, but not in game I am new to UDK and blender. I am using UDK3. I have tried the following so far Making the mesh origin, (0,0,0) Making the parent bone origin (0,0,0) Parenting the root bone with the mesh I have tried exporting in the following file formats .psk .fbx Both fbx and psk import into the UDK asset manager, and are viewable in the asset manager. I have also previewed my weapon Im importing against a chracter model, and it appears to be slightly too large (which is easy to fix). Many other forums mentioned for other people that the models might be displaying but be very very small. I have tried viewing in 3rd person 1st person (Weapon factory, and giving weapon via console command) I have made the blender file avaliable here http www.fileswap.com dl m1BiH78Gba The code is just standard wizard generated code and has worked previously for other weapon models. Any ideas or clues about how I can go about trouble shooting this would be greatly appreciated.
20
Importing a File Containing Two Objects from Blender into Unity Leads to a Single GameObject Not Two I have two separate objects in a Blender file (say a cube and a sphere). Unity import this file (OBJ type) as a single gameObject which is not want I want. I want cube and sphere to be two separate gameObjects.
20
Where is the "Scripts Window" menu in Blender 2.59? I'm trying to import a script into Blender, and I have the script in my directory and I pushed F8 to reload scripts, but the instructions for running this script say In the "Scripts Window" run "Scripts Export OGRE Meshes". I've seen other similar instructions for other scripts. But the toolbar only contains "File Add Render Help." Changing the "screen layout" to Scripting doesn't reveal any additional options, either. I'm sure I'm just missing something obvious. Please help!
20
Skeletal Mesh Cloth Simulation bug (UDK), unexpected behaviour When I try to move to the left (A) the pawn and the cloth move to the left, and when I move to the right (D) the pawn and the cloth move to the right too... Why the cloth always goes in same direction than the pawn? I would expect the cloth to go in the opposite direction, like dragged by the pawn. To anyone who's experienced with pawn with cloth simulation please help me T T Flag model for testing Flag bug
20
Blender to UDK 3 How to smooth Static Mesh I've created a bed cover model for my small game and here is how it looks like in blender http imgur.com T88Mnbs but whenever I import it to UDK it looks like this http imgur.com OMXBno3 it looks smooth in Blender but when I import to the Udk it doesn't Why is this happening? And I use .fbx to export from blender...
20
What's the rationale for different coordinates systems? Could someone explain to me why Blender and other 3D modeling apps switch axes? If I export model with Blender, then exporters do following things for the same model The 3DS format applies this transform matrix 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 1.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 1.0 The Collada format applies this transform matrix 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 1.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 1.0 The OBJ format (default) transforms axes just like a transform matrix was applied, but OBJ format (Forward Y, Up Z) gives the original values that I see in Blender. The PLY format also does nothing and I get same values I see in Blender. PS Question was edited. I do not ask why there are different coordinate systems. I understand that. I do not understand why Blender and other switch axis silently when model is exported. People in comments say It is easy to fix model after export There are people who needs that. Actually I never seen these people and if it easy to fix then it is more easy to switch axis for those who really need that switch. I would love to hear someone who say that axis switch is important and he she needs in real work (not in theory)
20
Blender How to "meshify" an object I made from Bezier curves I made a star shape using Bezier curves, and extruded it (see pic below) What I want to do is give it a rounder look not just around the edges by using beveling. I want it to kind of look like this (well, that shape anyway) How would I go about doing this? Please keep in mind that I am extremely new to Blender. I thought that I could somehow turn this star into those default shapes that have tonnes of squares which I could pull out, and apply a mirror to it so that the same thing happens on both sides. I really don't know how to do it, and would appreciate your help.
20
How are 3D game levels built? I am wondering what is the best most common practice in 3D games (mostly shooters) like Quake or Doom. How are the levels built? With larger, open spaces the answer is probably some kind of terrain editor, that is what I understand. But what about things like houses or closed areas? I see two main solutions. One is to make a whole house, factory, dungeon (or generally a level) in other tool, like Blender, and then put it in the game. Other is to make the most simple elements like walls, floor, doorways and make the level from them (like Lego blocks). Is one of the ways more common? More "industry standard"? Are there some obvious advantages or disadvantages?
20
Blender Bones get enlarged in export import process I have a rig in blender that I want to export into a different blender project. For some reason, when I do that, some of the bones get enlarged. All the scales are applied. Why might this be happening? I've no clue why this might be happening, as this problem seems exclusive to this project and one other project, where one bone out of the whole armature gets enlarges, but here is the information I can provide Some differences between the projects where this happens and the others is that the ones where this does happen have animations, and a pose library. However, this does not seem to cause the problem, as deleting the animations and poses doesn't change anything. This problem happens when I export import the project as an FBX. I usually export the project to unity and in order to compensate for the unity blender rotation, I follow this guide 1. I rotate the armature 90 on the x axis, apply rotation. Then rotate the armature 90 on the x axis but only apply the rotation to the mesh. I export the project as a FBX, with unity unit scale, no leaf bones, and the 3rd and 4th box under animations checked off. This also does not seem to cause the problem, as not rotating the armature and such doe not change anything.
20
Stretched textures in Blender First of all I'm relatively new to Blender. I discovered a weird bug in Blender 2.78c. On my object some textures are stretched although they are UV mapped. Since I have no clue why this is happening I took some screenshots which hopefully explain the problem. I tried various things, but found no way to solve this. Things I tried Unwrap again Apply Rotation and scale Manually adjusting verts in UV map Looking for "dead" verts somewhere in the model Does anyone know this strange behavior? Edit I uploaded my .blend file http pasteall.org blend index.php?id 47124 merged screenshots due to low reputation P
20
Correct way to export from blender to ogre format? When I export from blender to ogre using the blender2ogre add on, I'm not getting anything besides a scene most of the time and when I get a mesh I never get a material. Is there something wrong with my export procedure or what else could I be doing wrong? Update I can export the basic cube from blender to ogre but when I download a model and try to export it I don't get the meshes. Update 2 I tried again and selecting the model in Blender does the difference like the answer here says. I can export an alien and get the mesh and material I rename the files ls workspace DungeonWorld2 assets objects creatures alien Cube.001.mesh Material.002.material Material.005.material Cube.001.mesh.xml Material.003.material Cube.001.skeleton.xml Material.004.material dev dev OptiPlex 745 ls workspace DungeonWorld2 assets objects creatures alien alien.mesh Material.002.material Material.005.material alien.mesh.xml Material.003.material alien.skeleton.xml Material.004.material dev dev OptiPlex 745 But how do I actually load the material since the alien now turns up in the game with no material but it does render the mesh Spatial model3 assetManager .loadModel("objects creatures alien alien.mesh.xml") model3.scale(0.3f, 0.3f, 0.3f) model3.setLocalTranslation( 40.0f, 3.5f, 20.0f) rootNode.attachChild(model3)
20
Blender modelling for a C game? I want to know if it were possible to integrate models created with Blender into a game written in solely C .
20
What is the simplest way to export a bezier curve created in Blender to a text file? I have created a bezier curve in Blender. I'd like to export this curve to a text file. What I need is Control point handles, three points in total. Example 2.3333,4.3942, 55.333 , 0.3234, 2.4234, 4.0332 , 2.534, 6.S234, 12.0332 I have tried to export the scene in Collada format but it doesn't seems to include curves information. What is the easiest simplest way to export this curve to some readable text file format ?
20
Change text of bus destination sign at runtime I have rigged a bus in blender and imported it into Unreal. Now I want to change the text of the destination sign at run time. How can i do this?
20
Level design modular vs single project I'm working in Blender and UE4 for a while now... I always have the dillema of how to create my levels. My two ideas are a) modular like lego blocks. Create a wall, a floor, wall with hole for a window etc inside blender, and then, in UE4 make a level out of them. The advantage here is that I can arrange them however I want. The disadvantage is I always have a problem getting the elements to fit properly. Even if I scale one element up or down, everything else starts falling apart. b) single project make a whole object like a room or house in blender. Then everything connects nicely, but I'm always worried that it will be harder to edit, and I usually end up messing something. For example, whole house looks great, but inside the game a window is way too high, or the doors are too narrow to go through. My question What should I do should I stick to one method and try to fix the disadvantage? If yes, how would I do that? Is one of the methods considered "better" or the "industry standard"?
20
Can't load own .obj files from Blender to DX11 I'm currently trying to import objects to my game. My problem is that I'm able to load objects from online sites but it doesn't work for my own objects. It gives me an error Debug assertion failes. Expression vector subscript out of range. So I watched the value of my vector and realized that the faces are empty. The difference between my obj and these from the internet are that in mine the faces are like f 53 51 69 51 54 51 And in the files from online they look like f 3551 5154 3181 3666 5155 3182 3543 5151 3178 What do I wrong at exporting my blender object. I took a screenshot of my settings I hope you can help me.
20
Blender wont export textures (materials) to OGRE3D .mesh i am exporting a model from BLENDER to OGRE3D using the blender2ogre script. the desigre output is a single .mesh file but i know there should be also materials scripts that i should copy to my ogre path. the problem is that blender does not export those files for me it export only 1 mesh file (after i joined all objects) this is the model. in blender it looks fine but in my demo Ogre app it looks like i can use a little help here.
20
Can't move bone on blender. "Location" transform grayed out I'm trying to move a bone on Blender. I can't do anything with it at all. I've searched through the menus and noticed the Location transform is grayed out.
20
Stretched textures in Blender First of all I'm relatively new to Blender. I discovered a weird bug in Blender 2.78c. On my object some textures are stretched although they are UV mapped. Since I have no clue why this is happening I took some screenshots which hopefully explain the problem. I tried various things, but found no way to solve this. Things I tried Unwrap again Apply Rotation and scale Manually adjusting verts in UV map Looking for "dead" verts somewhere in the model Does anyone know this strange behavior? Edit I uploaded my .blend file http pasteall.org blend index.php?id 47124 merged screenshots due to low reputation P
20
Locating different models in a single scene I have a curiosity. Say I wanted to create a big forest using Blender, in this forest I'd like to have a campfire or several campfires. What I could do is create the entire scene in Blender with campfires included and of course in engine I would add a fire effect to it. Now what I do not understand is how can I actually find the fireplaces' locations in the engine? Since it's all in one scene, I can't just say getLocation on the model. I guess what I'm asking isn't how to do it per say, but what the "professional" way is. Do professional game developers fiddle around with coordinates until they find it? Do they load the campfire on top of the scene as a separate model and move it until it fits the scene? Just in case it is important, I am using jMonkeyEngine.
20
How can I prevent resizing of an Ogre3D object once imported into jMonkeyEngine? I created an object in Blender Then I exported it as a mesh.xml file and attached it to the game scene Note The gray color is the ground. In the game I end up with have a smaller, horizontal tower. Any suggestions? Note I exported the file with "Force Camera", "Force Lamps" and "Export Scene" unchecked and "Swap Axis x,y,z".
20
Blender Edge Split Alternative What other options alternatives are there to "edge split" for smooth shading low poly game models. As I understand it, edge split does what it say's, its splits the mesh therefore increasing the vert count. I have considered manually marking the edges as sharp however I would imagine this leaves artifacts on the model(in game) ? Cheers.
20
Change text of bus destination sign at runtime I have rigged a bus in blender and imported it into Unreal. Now I want to change the text of the destination sign at run time. How can i do this?
20
How do I correctly import an animation from blender into UE4? I have animated a conveyor belt in blender. When I import the animation to UE4, the conveyor belt does not move correctly. What am I doing wrong? Here is a link to my blender file Blender File
20
What's the rationale for different coordinates systems? Could someone explain to me why Blender and other 3D modeling apps switch axes? If I export model with Blender, then exporters do following things for the same model The 3DS format applies this transform matrix 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 1.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 1.0 The Collada format applies this transform matrix 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 1.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 1.0 The OBJ format (default) transforms axes just like a transform matrix was applied, but OBJ format (Forward Y, Up Z) gives the original values that I see in Blender. The PLY format also does nothing and I get same values I see in Blender. PS Question was edited. I do not ask why there are different coordinate systems. I understand that. I do not understand why Blender and other switch axis silently when model is exported. People in comments say It is easy to fix model after export There are people who needs that. Actually I never seen these people and if it easy to fix then it is more easy to switch axis for those who really need that switch. I would love to hear someone who say that axis switch is important and he she needs in real work (not in theory)
20
Blender wont export textures (materials) to OGRE3D .mesh i am exporting a model from BLENDER to OGRE3D using the blender2ogre script. the desigre output is a single .mesh file but i know there should be also materials scripts that i should copy to my ogre path. the problem is that blender does not export those files for me it export only 1 mesh file (after i joined all objects) this is the model. in blender it looks fine but in my demo Ogre app it looks like i can use a little help here.
20
How to export an IK structure created in Blender 2.8 to Godot 3.1? I created this IK bone structure in Blender 2.8 and exported as .escn As you can see, in Blender it's working ok. Now, how to use it in Godot? I've tried export with .dae (native) .dae (Better Collada) .escn .glb None of them worked... Is there any tutorial for using imported IK in Godot?
20
what are texcoord tags in mesh.xml file in Ogrexml format? I exported a 3d model from blender 2.79 and using ogrexml import export plugin. but the texture will crash and UV map not working in that format. I made the model by four parts head body hands shoes and they have 4 material and 4 textures, so I made a texture atlas for it and join them in a mesh to More optimization. I think removing other UV maps has a problem because when I check the model.mesh.xml in a note editor and every vertex has 3 texture coordinate tags and I compared it with a normal correct model that looks good in the blender and in ogrexml format, it has one texcoord tag inside of vertex tag. 1 what are texcoord tags? are they using for UV maps in ogrexml format? 2 how can I clear blend files from other unused uvMaps to avoid exporting them with the model?
20
Blender Unity materials problem I have a pproblem with materials and their texture. I have a model with 1 material called 'Car Jack', after i put my .blend file into unity, unity adds 'Car Jack Car Jack UV', which is white material without textures. I have the only one UV map, called 'Car Jack UV'. What is wrong with Unity Blender?
20
How to export an IK structure created in Blender 2.8 to Godot 3.1? I created this IK bone structure in Blender 2.8 and exported as .escn As you can see, in Blender it's working ok. Now, how to use it in Godot? I've tried export with .dae (native) .dae (Better Collada) .escn .glb None of them worked... Is there any tutorial for using imported IK in Godot?
20
Getting .mesh .skeleton from Blender2Ogre export I have downloaded the add on blender2ogre from this source http code.google.com p blender2ogre And I have created a simple mesh, with walking animation (similar to the gingerbreadman tutorial). My question is, whenever I want to export the project, I can only see the .scene export format. There is no option whatsoever to export as .mesh and .skeleton. Also, how can I export the walking animation separately, in other words, if my project have couple more animation, how can i separate those during export?
21
Good way of handling class instances in game development? I'm a new indie game developer, and I've made a few games, but often times when coding I wonder "Is this the way most people do it? Am I doing it wrong?" because I'd like to become a game developer some day, and I really want to get rid of bad practices in time. The way I'm doing it right now is like this include lt some libraries gt include "Some classes" int main() Class1 a Class2 b Class3 c a.init() b.init() c.init() game logic Now as I see the game grow, I have more and more classes to initialize and create instances of. This is clean but I'm not sure if this is standard practice. Is this a regular way of creating instances of your game classes or is there a cleaner and more efficient way to do it?
21
is wisdom of what happens 'behind scenes' (in compiler, external DLLs etc.) important? I have been a computer fanatic for almost a decade now. I've always loved and wondered how computers work, even from the purest, lowest hardware level to the very smallest pixel on the screen, and all the software around that. That seems to be my problem though ... as I try to write code (I'm pretty fluent at C ) I always sit there enormous amounts of time in front of a text editor wondering how every line, statement, datum, function, etc. will correspond to every Assembly and machine instruction performed to do absolutely everything necessary for the kernel to allocate memory to run my compiled program, and all of the other hardware being used as well. For example ... I would write cout lt lt "Before memory changed" lt lt endl and run the debugger to get the Assembly for this, and then try and reverse disassemble the Assembly to machine code based on my ISA, and then research every .dll, library file, linked library, linking process, linker source code of the program, the make file, the kernel I'm using's steps of processing this compilation, the hardware's part aside from the processor (e.g. video card, sound card, chipset, cache latency, byte sized registers, calling convention use, DDR3 RAM and disk drive, filesystem functioning and so many other things). Am I going about programming wrong? I mean I feel I should know everything that goes on underneath English syntax on a computer program. But the problem is that the more I research every little thing the less I actually accomplish at all. I can never finish anything because of this mentality, yet I feel compelled to know everything... what should I do?
21
How to implement zombie AI? We need to make a zombie videogame for a semester project and I was wondering about what are considered nice algorithms techniques for implementing zombie AI that don't take too long to implement. The project is a videogame product, involving other stuff as physics and multiplayer, so we have limited time, so what I'm specifically looking for is A quick amp dirty way to implement zombie AI (I'm thinking on neural networks or perhaps even fuzzy logic) Common ways of implementing and optimizing zombie AI The ideal way of implementing zombie AI (I imagine it would involve pathfinding, or even swarm intelligence?) General advice on zombie AI Considering that the quick amp dirty implementation would perhaps be a place holder for another and better algorithm technique. Thanks in advance.
21
Relevant file paths for reading in from a file? Working on something in XNA, need to be able to read in data from a text file for something. Trying to figure out how I can shorten this pathname down, so instead of it always checking there, it just checks in the directory where the actual program is. I tried doing " Data Zone " filenamestring ".txt" as my path but it didnt work. What I have that works Sub loadFromFile(ByVal fileNameString As String) If System.IO.File.Exists("C Users user documents visual studio 2010 Projects asdf asdf asdf Data Zone " fileNameString ".txt") Then MsgBox("It found it.") Else MsgBox("Could not find it") End If End Sub While this works, unfortunately this will probably only work on my machine. How do I shorten the file path so its flexible and relevant to the directory where the program is actually located at?
21
How are the same items generated with slightly different attributes? Consider games like Destiny. How do they generate weapons that have the same skins and names, but different attributes? Two people can have the same weapon or armor piece, but have different attributes on these pieces based on luck or drop rate etc. How is this accomplished programmatically?
21
try to create CCSpriteFrame but get nil values I'm trying to animate a CCSprite in cocos2d v3 following this question, but I'm getting the following error message in Log Terminating app due to uncaught exception 'NSInvalidArgumentException', reason ' NSArrayM insertObject atIndex object cannot be nil' This is my code NSMutableArray animationFrames NSMutableArray array int frameCount 0 for(int i 1 i lt 9 i) CCSpriteFrame spriteFrame CCSpriteFrameCache sharedSpriteFrameCache spriteFrameByName NSString stringWithFormat "hero d.png", i animationFrames addObject spriteFrame ERROR OCCUR THIS LINE frameCount if (frameCount 8) break The problem is that all spriteFrames are nil, but I don't why. I already tested the i values with NSLog, and also tried to add hero 1.png to a CCSprite object and works fine. I also tried to add all fixed hero 1.png in all frames to verify if the problem was with i variable. But didn't work also.
21
What is an OO way for my input layer to act upon objects? I'm building a top down RPG specifically to practice Object Oriented thinking and design. I am keeping in mind coupling, single responsibility, and so forth. One design issue that's been bugging me is how to ultimately have objects talk while maintaining the loosest coupling possible. As an example, I'm designing the input class now, which will be made up of two layers, like so The conundrum is that I don't know how to bridge that gap between Input and HeroActor, which is initialized from the PlayState class, which is also where the hero.update() method is called. Let's say Keyboard has just executed public void keyPressed(KeyEvent e) switch(e.getKeyCode()) Some cases case KeyEvent.VK UP Assume InputEvent.INPUT1 is a defined enumeration in InputEvent inputHandler.passInput(InputEvent.INPUT1) break Some more cases I've basically landed here public class Input public void passInput(InputEvent e) switch(e) Some cases case InputEvent.INPUT1 ???????????????????? Some more cases My ideas have been Pass a reference to the instance of HeroActor to the Input object, then have Input directly call the moveUp() method on the HeroActor instance. case InputEvent.INPUT1 actor.moveUp() My instinct tells me this is bad OO design as it tightly couples the two classes. Make the instance of HeroActor global and basically do the same as above. Even worse OO design. Write a registerInput(Input inputHandler) function in the Actor class, like so public class HeroActor extends Actor Existing fields and methods private Input inputHandler public void registerInput(Input inputHandler) this.inputHandler inputHandler Still, then the HeroActor would have to poll the inputHandler every frame to find out if any actions have applied to it. I'm in the same situation trying to figure out how to write the collision engine without passing it specific references to the player's HeroActor instance or the dozens of EnemyActor instances in the PlayState constructor. Any help would be greatly appreciated. My request is not for specific code, but rather common techniques for handling the many objects in a game without ending up with a god object. I've seen some material suggesting an Observer pattern being applied for things like the input layer above, but before I go too far, I'd like some feedback from the community since I've got so many different answers among all of my Googling today.
21
How to setup a client to work with a remote server or a local included server? I'm working on a Networked multiplayer game, but while developing and for testing I want to set up a local server that acts like the multiplayer server. My thought is to approach the server as a proxy setup. Creating a class that the client sees and essentially allowing it to either load the server code in itself or to use a networking layer. Is this a good approach? Are there other approaches to look into? What pitfalls should I be watching for? Update A bit more specifically I need to do this because I am targeting the Ouya and I can't guarantee a network connection, or even a spare machine to run the server on. And inside Android it is more difficult to setup and launch a service rather than include my server code right into a client build.
21
What makes a good educational game? I'm currently creating a game framework engine for educational games. My hope is that this can be used in elementary schools. It is of course extremely important that the games are both fun and educational. Any ideas what should be in my initial requirement specification? What makes a good educational game? Which platforms should I target?
21
Should a server run all maps in one loop, or a thread game loop per map? I'm working on a real time multiplayer browser based game. The game is top down on variable size tile based maps. There is no central map where all players come together, the entire game plays out in multiple maps. (Player chooses one on login, but has the ability to switch whenever they want). Let's take the following loop that runs on the server side of things let tick time Duration from millis(500) e.g. Tick 2 times per second. let mut next tick Instant now() loop let now Instant now() if now gt next tick Parse user input Update state Update to state to users in map next tick tick time else let wait time next tick now sleep(wait time Duration from millis(1)).await In my 'map based' gameplay scenario, would it make sense to spawn a thread for every map where one of these loops runs? Or would it be recommended to have only a singular thread with a singular game loop that updates every map? Or is there perhaps a better, already existing, pattern for this?
21
Why are there fewer glitches in current day games? I remember that almost every single game in the early 2000s had at least a few amusing glitches, mostly related to animations, that often produced funny situations. I also remember that game magazines used to dedicate a section with the funniest screenshots people sent in. As an example, I was just playing Far Cry from 2004 and out of nowhere, whenever I killed some bad guy, instead of dropping to the ground they'd start playing the running animation. This was getting me confused since I was trying to shoot them down from a large distance and didn't understand why they weren't dying. I've rarely seen stuff like this in current day games. Was there some change in the technique used to develop games that would make these programmer mistakes less likely? P.S. I'm not talking about RPGs and other inherently complex genres. I'm talking about games like Far Cry shooters like Battlefield 3, Modern Warfare 3, even Mass Effect. I've seen plenty of glitches in games like The Witcher 2, Skyrim, etc.
21
Is it possible to program the entire logic and flow of a game without ever touching a graphic's engine? I'm not interested in rendering engines or level design, but I'm very interested in programming the AI that drives all of the characteristics of game play. I'm thinking of how the d20 system drives the rules behind D amp D games. Is there a person that programs that logic, and is it possible to program almost all of an API without ever touching a graphic's engine? I'm a software engineer by trade (Java with some C experience), so I'm looking to use those programming skills.
21
What math should all game programmers know? Simple enough question What math should all game programmers have a firm grasp of in order to be successful? I'm not specifically talking about rendering math or anything in the niche areas of game programming, more specifically just things that even game programmers should know about, and if they don't they'll probably find it useful. Note as there is no one correct answer, this question (and its answers) is a community wiki. Also, if you would like fancy latex math equations, feel free to use http mathurl.com .
21
What are standard methods for organizing game code? Grouping by standard "kinds" of methods? I've made a few games, and am getting faster and better organized each time. I'm well out of the "just make it work" phase and working on methodology and readability. I need some tips on code organization though. I don't mean patterns I'm having great success with MVC but the organization of methods inside the classes themselves. I've noticed that methods in my state models can usually be grouped into four categories (1)constructor destructor, (2)data access (3)actions (4)events. My controllers usually have c d and input methods. My views usually have c d, view updaters, and event listeners. I feel like I'm reinventing the wheel though someone must have spelled out "these are the common types of methods" somewhere before, right? Storage has Create, Read, Update and Delete (CRUD), so what are the equivalents for objects? EDIT Found some cocoa specific advice here http www.mactech.com articles mactech Vol.21 21.07 StyleForCocoa and some generic advice here https stackoverflow.com questions 73045 whats the best way to organize code 73081 73081 I'm going to use that as a foundation, modified for game specific stuff. More info still appreciated if you have any.
21
Limitations of p2p multiplayer games vs client server I am reading up on multiplayer game architecture. So far most of the articles i've found deal with the client server model. I'd like to know what are the limitations for using a p2p architecture? what "class" of games are possible (or more common) to implement using it? which aren't? and in general, what are its main differences and limitations against the client server model.
21
How do I implement a racing clock that shows elapsed time? I'm wanting to make a old school timer like the picture below. How would I go about doing this in VD? I have tried it doing it with code bellow. The problem with this is that it starts with just seconds only adds the minutes section when you reach 1 minute. Dim StartTime As DateTime Dim PlayTime As TimeSpan Private Sub Form1 Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load StartTime Now() End Sub Private Sub tmrCountUp Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCountUp.Tick PlayTime Now() StartTime lblTime.Text PlayTime.Hours amp PlayTime.Minutes amp PlayTime.Seconds lblTime.Text lblTime.Text 1 End Sub
21
How to make gravity in Blitz3D? I am making a game in Blitz3d and I made simple gravity, however once the object falls on the ground, it goes through it very slowly. The ground is a plane and I have collision on it. This is a pretty old engine, and not a lot of people are using it but I decided to use it because it's easier than Unity3D for me and it's very basic and customizable. Here's my code AppTitle "FPS" Graphics3D 800,600,32,2 SetBuffer BackBuffer() SeedRnd MilliSecs() HidePointer Objects Global player CreatePivot() Global camera CreateCamera(player) Global cube CreateCube() Global light CreateLight() Global plane CreatePlane() Global cube2 CreateCube(player) col plane 1 col player 2 col cube 3 Vars gravity .00001 plx 0 ply 0 plz 0 pldx 0 pldy 0 pldz 0 Textures CameraClsColor camera,135,206,250 box LoadTexture("models box.png") dirt LoadTexture("models dirt.jpg") Object Details EntityType cube,col cube EntityType player,col player EntityType plane,col plane EntityRadius player,1.2 EntityRadius plane,1 PositionEntity player,0,10,5 PositionEntity cube,0,1,5 PositionEntity light,0,2,0 PositionEntity plane,0,0,0 EntityTexture cube,box EntityTexture plane,dirt ScaleTexture dirt,5,5 CameraRange camera,0.25,200 Called Functions While Not KeyHit(1) Cls Collisions Collisions col player,col plane,2,2 Collisions col player,col cube,2,2 If ply lt 2 Then ply 0 pldy pldy .39 EndIf If ply lt 1.8 Then pldx .6 pldx pldz .6 pldz If KeyDown(57) Then pldy 2 EndIf pldy pldy gravity plx plx pldx ply ply pldy plz plz pldz PositionEntity player,EntityX(player) plx,EntityY(player) ply,EntityZ(player) plz control() RenderWorld() UpdateWorld() MoveMouse GraphicsWidth() 2, GraphicsHeight() 2 Flip Wend End Functions Function control() If KeyDown(42) Shift (for running) If KeyDown(17) And KeyDown(30) W and A MoveEntity player, 0.15,0,0.15 ElseIf KeyDown(17) And KeyDown(32) W and D MoveEntity player,0.15,0,0.15 ElseIf KeyDown(17) And KeyDown(30) S and A MoveEntity player, 0.15,0, 0.15 ElseIf KeyDown(17) And KeyDown(32) S and D MoveEntity player,0.15,0, 0.15 ElseIf KeyDown(17) W MoveEntity player,0,0,0.15 ElseIf KeyDown(31) S MoveEntity player,0,0, 0.15 ElseIf KeyDown(30) A MoveEntity player, 0.15,0,0 ElseIf KeyDown(32) D MoveEntity player,0.15,0,0 End If Else Walking If KeyDown(17) And KeyDown(30) W and A MoveEntity player, 0.1,0,0.1 ElseIf KeyDown(17) And KeyDown(32) W and D MoveEntity player,0.1,0,0.1 ElseIf KeyDown(17) And KeyDown(30) S and A MoveEntity player, 0.1,0, 0.1 ElseIf KeyDown(17) And KeyDown(32) S and D MoveEntity player,0.1,0, 0.1 ElseIf KeyDown(17) W MoveEntity player,0,0,0.1 ElseIf KeyDown(31) S MoveEntity player,0,0, 0.1 ElseIf KeyDown(30) A MoveEntity player, 0.1,0,0 ElseIf KeyDown(32) D MoveEntity player,0.1,0,0 End If End If While KeyDown(16) Q RotateEntity camera,MouseXSpeed(),10,10 Wend While KeyDown(18) E RotateEntity camera,0, 10, 10 Wend TurnEntity player, 0, MouseXSpeed() 6.0, 0 TurnEntity camera, MouseYSpeed() 6.0, 0, 0 If EntityPitch(camera) lt 70 RotateEntity camera, 70, EntityYaw(camera), EntityRoll(camera) ElseIf EntityPitch(camera) gt 70 RotateEntity camera, 70, EntityYaw(camera), EntityRoll(camera) EndIf End Function If there's some one who can actually help me with this, I would appreciate it.
21
Experiences of test driven devleopment in large projects I've used TDD in personal projects, but I wondered if anyone had any experience of using this approach across a large team? Was there resistence to the test first approach? Did you keep code coverage high for the whole project? How did coverage survive fixing those two in the morning and you ship in four hours crash bugs? Did you run tests on all platforms, or just assume that passing on one meant passing the others? I love the decoupled code that TDD produces, and the large suite of regression tests you get for free, but if you only have a few in the team who don't want to contribute tests, won't everyone suffer?
21
Best solution for "level string"? I have a game that generates a random level map at the start of the level. I want to implement some way to save and load the level. I was thinking maybe XML would be a good option for saving all the variable, then it would be easy for me to build something that can parse that XML and generate the exact same level. But XML is probably overkill for my needs. I remember back in the day with the old Sega console that didn't have the ability to save your game (I think the Worms game did it too), that they would give you a bunch of character that you could write down. If you punched in that string later on, it would load the exact level. Would a "level string" be a good option? Would it be some kind of "base60" conversion? How would I implement this?
21
Are there cases where globals singletons are useful in game development? I know that having global variables or singleton classes creates cases that can be difficult to test manage and I have been busted in using those patterns in code but often times you gotta ship. So are there cases where global variables or singletons are actually useful in game development?
21
Best solution for "level string"? I have a game that generates a random level map at the start of the level. I want to implement some way to save and load the level. I was thinking maybe XML would be a good option for saving all the variable, then it would be easy for me to build something that can parse that XML and generate the exact same level. But XML is probably overkill for my needs. I remember back in the day with the old Sega console that didn't have the ability to save your game (I think the Worms game did it too), that they would give you a bunch of character that you could write down. If you punched in that string later on, it would load the exact level. Would a "level string" be a good option? Would it be some kind of "base60" conversion? How would I implement this?
21
Should a server run all maps in one loop, or a thread game loop per map? I'm working on a real time multiplayer browser based game. The game is top down on variable size tile based maps. There is no central map where all players come together, the entire game plays out in multiple maps. (Player chooses one on login, but has the ability to switch whenever they want). Let's take the following loop that runs on the server side of things let tick time Duration from millis(500) e.g. Tick 2 times per second. let mut next tick Instant now() loop let now Instant now() if now gt next tick Parse user input Update state Update to state to users in map next tick tick time else let wait time next tick now sleep(wait time Duration from millis(1)).await In my 'map based' gameplay scenario, would it make sense to spawn a thread for every map where one of these loops runs? Or would it be recommended to have only a singular thread with a singular game loop that updates every map? Or is there perhaps a better, already existing, pattern for this?
21
Do retail games use "inversion of control" and "dependency injection"? Many of the more diligent software developers I know are moving to inversion of control and dependency injection to handle references to objects. Coming from a Flash games perspective I don't know all the ins and outs of AAA studios, so are these used in the retail game world?
21
What is "tools development?" I have been looking at different jobs in the games industry and a lot of the jobs that I have seen advertised are for a "Tool Developer" position. I do not know what this actually is. Could someone explain what this is to me please? And if anyone has any links to material that would help me understand it more then that would be very much appreciated.
21
What should a game engine do? I'd like to improve my skills try something new and I'd like to start with 3D. I have read Starting programming in 3D with C but I have question about engines What should engine do? I know it is abstraction layer above 3D API (i.e. OpenGL or DirectX) but what should it exactly do?
21
Time critical events based on framerate Problem Description Basically, I've made a "programming game" in which I've made my own scripting language. It is a completely standard Lunar Lander game, though instead of directly controlling the lander using keyboard input, it instead fires a sequence of commands you have provided through the scripting language I made. This all works, and I've hit a critical problem. So essentially, using the scripting language, you specify something like After 5 seconds, activate thrust for 10 seconds, and then after 2 seconds, rotate the lander for 4 seconds. The goal is then to chain together a sequence of commands which will get you to land the lander safely. Of course, this comes with one problem. If you repeat the sequence of commands, each command will have to be fired at exactly the same spot in the level, that is, after x amount of seconds, but also with the lander being in the exact same spot. If you did not use timer based movement, sure you could indicate that a command should activate after 5 seconds, but the lander moving at 60 FPS would have moved way further than a lander moving at 30 FPS. Why of course, I thought I would simple just make the lander use timer based movement so it is independent of FPS (I am using the very standard approach of taking the amount of time passed last frame, and multiplying it to a constant move speed). Then I would count seconds using the system clock. So the after x amount of seconds, the lander would be in the same spot in the level when the command activates. Unfortunately, this approach do not work. Every time I run a sequence of commands, they will be activated with, sometimes very slight, variations, making it impossible to actually get a consistent and reliable path for the lander. My Question So my question is, am I tackling this problem a completely wrong way? What exactly do you do when it is absolutely critical that timed events defined by the user will activate at exactly the same time and spot in a level? I seem to be quite stuck with this question.