Jump to content
  • Advertisement

Dante1995

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

107 Neutral

About Dante1995

  • Rank
    Newbie
  1. Dante1995

    SDL 2.0 Texture Rendering Help

    I think I got what you are trying to say   but what if I don't want to load the image with the function rather I want it to load manually? then? isn't my way of loading it manually correct? correct me if I am wrong
  2. Dante1995

    SDL 2.0 Texture Rendering Help

    sorry brother. I did not get what you said :( can you be more specific?? :( I am new in SDL so don't know the real mechanism till now
  3. Dante1995

    2D game library help

      Plenty of people use SDL and SFML. For 2D graphics, those are usually what you want to use.   OpenGL and DirectX are for 3D graphics - though they can do 2D just fine as well, they are more complicated because they're more general purpose. SDL and SFML provide wrappers around DirectX or OpenGL to intentionally simplify things in a good way, without dumbing things down or slowing things down.   I've used SDL and SFML extensively, and currently am using SFML (and other libraries).   About engines: No, I'd suggest you do things "manually" for learning purposes, when working on 2D games. I advocate, in general, against engines for 2D games and for engines for 3D games. I've pontificated about it in other threads that I could dig up if you care about the why's, but in short, my advice would be to forget the word "engine" at this point of the learning process, and instead focus on making small 2D games "from scratch" using 3rd party libraries like SDL or SFML, and using other 3rd party libraries as needed.   As for books, I definitely recommend getting two C++ books - one that's a heavy textbook teaching modern C++11/C++14 practices, written within the last two years. And another that's just a fun smaller book you can flip-through on the couch for fun or use as a reference. I don't have any specific recommendations here, since the ones I used are now obsolete.   However, I don't recommend getting any library-specific books, like SDL or SFML books. SDL and SFML are simple enough you can read online tutorials, google when you have questions, and post here on GameDev or on the SDL or SFML forums when you really get stuck.    After programming for a year or two, there are more heavy duty C++ or general programming books that can improve your programming abilities further - but for now, it sounds like you're probably at the "syntax and features" level of learning, and those kind of books would be more confusing than anything. When learning a more complex library like OpenGL or DirectX, it may be worthwhile getting some books, but I'd hold off on that for now - it'd be a waste of money, because by the time you are really ready for them, those library-specific books will be (mostly) outdated.    And don't forget to check your library to see if they have any recent programming books... but don't read language-specific or library-specific books that are more than two years old. Older general programming concept books are fine though.   Hope that helps! Good luck on your programming journey.    thanks Sir for you answer. it was really appreciable :) and yeah I am really learning SDL from scratch. I am following Tut from youtube and from lazyfoo.net they are good by the way :) and I have one book named "SDL game developemnt" (forgot the author name, something starts with R, and publisher is PACKT i think) which I will follow after I grasp all the general knowledge of SDL. and for C++ I have books also. C++ is not a problem for me. because I know it well. and about C++14 features I will definitely catch them (thanks for the info, I did not know that C++14 even exists now :P )  actual reason for this post was to know if SDL is better than SFML and Allegro. and also if learning 2D libraries is wise decision or not when we see 3D games eveywhere. Well now I know to make 3D game, I must have knowldge of 2D game :) thanks for it :)
  4. hello guys, I am learing SDl 2.0 now. I have made a window,renderer, and some textures where I have put my srpite sheet. animation is working fine but I wan to add another texture(background which will be) behind the sprite animation. have added the texture and also SDL_RenderCopy() it. but it's not showing. please help stuck with it.. below is my code.   #include<iostream> #include<SDL.h> #include<SDL_image.h> #include<string> using namespace std; float frameTime=0; int prevTime=0; int currentTime=0; float deltaTime=0; float moveSpeed=300.0f; SDL_Texture *loadTexture(string filepath,SDL_Renderer *renderTargetOp){ SDL_Texture *texture=NULL; SDL_Surface *surface=IMG_Load(filepath.c_str()); if(surface==NULL) cout<<"Error"<<endl; else{ texture=SDL_CreateTextureFromSurface(renderTargetOp,surface); } SDL_FreeSurface(surface); return texture; } int main(int argc, char* argv[]){ SDL_Window *window=NULL; SDL_Renderer *renderTarget=NULL; SDL_Surface *bgSurface=IMG_Load("grass.png"); SDL_Texture *bgTexture=SDL_CreateTextureFromSurface(renderTarget,bgSurface); SDL_Rect bgRect; bgRect={0,0,640,480}; SDL_FreeSurface(bgSurface); bgSurface=NULL; SDL_Texture *currentImage=NULL; SDL_Rect playerRect; SDL_Rect playerPos; playerPos.x=300; playerPos.y=200; playerPos.w=30; playerPos.h=30; int frameWidth,frameHeight; int textureWidth, textureHeight; int imgFlags=IMG_INIT_PNG | IMG_INIT_JPG; if(!(IMG_Init(imgFlags) &imgFlags)) cout<<"Error "<<IMG_GetError<<endl; if(SDL_Init(SDL_INIT_EVERYTHING)<0){ cout<<"Int error: "<<SDL_GetError()<<endl; } else{ window= SDL_CreateWindow("Bullshit Crap",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,640,480,SDL_WINDOW_SHOWN); if (window==NULL){ cout<<"window creation error: "<<SDL_GetError()<<endl; } renderTarget=SDL_CreateRenderer(window,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); currentImage=loadTexture("image.png",renderTarget); SDL_QueryTexture(currentImage,NULL,NULL,&textureWidth,&textureHeight); frameWidth=textureWidth/3; frameHeight=textureHeight/4; playerRect.x=playerRect.y=0; playerRect.w=frameWidth; playerRect.h=frameHeight; bool running = true; SDL_Event ev; while(running){ prevTime=currentTime; currentTime=SDL_GetTicks(); deltaTime=(currentTime-prevTime)/1000.0f; while(SDL_PollEvent(&ev) !=0){ if(ev.type==SDL_QUIT) running=false; else if(ev.type==SDL_KEYDOWN) switch(ev.key.keysym.sym){ case SDLK_RIGHT: playerPos.x +=deltaTime*moveSpeed; break; case SDLK_LEFT: playerPos.x -=deltaTime*moveSpeed; break; case SDLK_UP: playerPos.y -=deltaTime*moveSpeed; break; case SDLK_DOWN: playerPos.y +=deltaTime*moveSpeed; break; } } frameTime+=deltaTime; if(frameTime>=0.10f){ frameTime=0; playerRect.x += frameWidth; if(playerRect.x >=textureWidth) playerRect.x=0; } SDL_RenderClear(renderTarget); SDL_RenderCopy(renderTarget,bgTexture,NULL,&bgRect); SDL_RenderCopy(renderTarget,currentImage,&playerRect,&playerPos); SDL_RenderPresent(renderTarget); } } SDL_DestroyWindow(window); window=NULL; SDL_DestroyTexture(currentImage); SDL_DestroyTexture(bgTexture); bgTexture=NULL; SDL_DestroyRenderer(renderTarget); currentImage=NULL; renderTarget=NULL; SDL_Quit(); return 0; }
  5. Dante1995

    2D game library help

    Let's see !! thanks for the encouragement :)
  6. Dante1995

    2D game library help

    i don't know brother. I use only SDL2
  7. Dante1995

    2D game library help

    thanks brother :)
  8. Dante1995

    2D game library help

    Thanks for helping. then I should continue my learning SDL. by the way do you have any extra resources where you will learn from scrath. I tutorial I am following is good but I want all the details as I wanna master SDL2. So any light on that?
  9. Dante1995

    2D game library help

    hello guys. I am totally new to Game programming.. I have basics knowldge of C++. and have started learning SDL tutorial from lazyfoo.net and finding it interesting. but when I searched about SDL, it seemed to me that nowadays people hardly use SDL SFML etc 2D libraries, rather than they use OpenGL, DeirectX etc. so is it good to begin game prograaming with SDL or I should move to 3D libraries or any other 2D libraries before going deep into SDL. one more thing is it good to use a Engine? or should I continue learning developing games manually? I need help plz. and lazyfoo's tutorial is good but sometimes it's not so clear. do you guys have any other resources or Books? if yes then please suggest me. Thanks in advance ! 
  • 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!