Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by twety94Gmail

  1. Hello. I am curious, how should i handle my actions in game. I am making a 2D Rpg. I am not sure what to search as tutorial vise. Basically i have a "Player" and if he uses lets say button "a" (which is attack) i will run animation swing sword, but my problem starts here how do i check that something is supposed to get hit? collision detection?. And interacting with NPC. W(is talk button / interact) i wanna make it realistic and he should be facing the NPC and be close, only then he can start the conversation, again should i detect if hes "calculate where the NPC facing position is" and check for that, or how do people usually make it. any help is appreciated. RPG = Role Playing Game NPC = Non Player Character
  2. Hello. Im doing a 2d tiled based rpg. i was fine with per loop movment, but then i had to add a animation to all that, and it dosent look fluent. So i went exploring and found that i need to find delta time and som other stuff. So basicly this is my game: int main(int argc, char* argv[]) { while(On) { FPSTimer = SDL_GetTicks(); LastTime = CurentTime; CurrentTime = SDL_GetTicks(); SpeedFactor = (CurrentTime - LastTIme) * 1000.0f; //Events //MainLogic //Render if(1000.0f / Screen_FPS > (SDL_GetTicks() - FpsTimer)) SDL_Delay(1000.0f / Screen_FPS - (SDL_GetTicks()- FpsTimer)); } } void Events() { x += (MovmentSpeed * speedfactor); } Movment speed = 50; and i want to move my "X" hero position by 50 pixels each loop but i never had ani complicated math at school cant figure it out. Screen_FPS = 60
  3. Hello. My problem is c++ related on my lack of knowlage. I have a fT whic i use for Timed Movment. In function Main::ActionHandle() i call the calculation where problem ocures. when i blit HeroCropF(float) and Position(float) should be same right? i use same calculations and values. But "Position" changes while "HeroCropF" stay 0. il post whole code if this isent enought but i got just bacis SDL Event/Render only. int Main::MainStart() { if(Init() == false || Load() == false) { Exit(); return -1; } SDL_Event ImpEvent; while(Running) { oT = cT; cT = SDL_GetTicks(); fT = (cT - oT) / 1000.0f; FpsTimer = SDL_GetTicks(); while(SDL_PollEvent(&ImpEvent)) { EventHandle(&ImpEvent); } ActionHandle(); RenderHandle(); if(1000.0f / Screen_FPS > (SDL_GetTicks() - FpsTimer)) SDL_Delay(1000.0f / Screen_FPS - (SDL_GetTicks()- FpsTimer)); } Exit(); return 0; } float Main::ReturnfT() { return fT; } void Main::ActionHandle( { Hero::HeroControl.AnimateHero(); Position += 4.0f * fT; } void Hero::AnimateHero() { HeroCropF += 4.0f * Main::MainControl.ReturnfT(); } Edit: Btw Position changes for 4 Pixels per second, so should the HeroCropF but it dosent... Ani value with Position works perfect. Edit2: I changed this: void Main::ActionHandle( { Hero::HeroControl.AnimateHero(); Position += 4.0f * fT; } TO THIS!!!: void Main::ActionHandle( { Hero::HeroControl.HeroPosF += 4.0f * fT; Position += 4.0f * fT; } And now it works. So the error is Passed "fT" value ? wtf can som1 explain the error there
  4. twety94Gmail

    Function return value problem?

    i am grabbing "fT" from "Main::MainControl.ReturnfT()" and as you say its incorrect since it does not work. i tried making "fT" public in Main Class. and grabing it with "Main::MainControl.fT" did not work. I do not want to trouble you with this anymore. What area of C++ should i look intro to fix this problem? what would you recommend? I never figured what are the red underlines for until now =,=
  5. twety94Gmail

    Function return value problem?

    Yes i noticed it now... i made error during pasting =,?. Mhm i can send you File.zip? i dont see a "Attach File" Project file is CodeBlock compiler mingw32 if it helps i uploaded Karg.zip to Mediafire Link: http://www.mediafire.com/?3r0421j883qld80 Sry for my ingrish. I have no class for it.
  6. twety94Gmail

    c++ SDL, Time step problem

    Thanks peous for help. i knew its something simple, chouldnt figure it out.
  • 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!