Ped Xing

  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Ped Xing

  • Rank
  1. asBSTR and bstr

    I'm having trouble making my script file read a *bstr from my host program. I define the bstr like so: asBSTR *timeStr; I register the bstr like so: r = engine->RegisterObjectProperty("CGame", "bstr timeStr", offsetof(CGame, timeStr)); assert( r >= 0 ); Then I have a function that returns a Time String: asBSTR* TimeString() { char buffer[100]; if (game.min < 10) { if (game.sec < 10) sprintf(buffer, "0%d'0%d", game.min, game.sec); else sprintf(buffer, "0%d'%d", game.min, game.sec); } else { if (game.sec < 10) sprintf(buffer, "%d'0%d", game.min, game.sec); else sprintf(buffer, "%d'0%d", game.min, game.sec); } return (asBSTR*)buffer; } Then every frame I make game.timeStr = TimeString(); inside of my host. When the player dies I want a script file to print the time that he played. So I do this: bstr s = "Time: "; s += game.timeStr; And it crashes my progam. Any advice?
  2. Something like printf in angelscript

    There is nothing wrong with bstr. I just had a few problems in my code and it's all working now. Using the bstrFormat will work fine for what I need. thanks
  3. is there a way to achieve something like printf("blah %d", var); in angelscript (preferably using bstr)? How can I add numbers into a bstr in the script file? I tried bstr s = ""; s = bstrFormat(game.score); but that didn't work.
  4. AngelScript 1.8.0 WIP #4 (2004/07/03)

    What does the code generation settings for Release need to be? I am using a game lib that the creator suggested I use Single Threaded. I get a lot of errors when compiling for relese, but everything is fine for debug. I heard that this kind of thing can happen when you use libs of different code generations. My debug code generation is set on debug multithreaded dll. So, I tried Multithreaded DLL for release and I get 100 link errors. Here are a few: angelscript.lib(as_variablescope.obj) : error LNK2001: unresolved external symbol __ftol ac_string.obj : error LNK2001: unresolved external symbol __imp__strstr angelscript.lib(as_compiler.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) hgehelp.lib(hgeparticle.obj) : error LNK2001: unresolved external symbol __fltused Here is what I link against: kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hge.lib hgehelp.lib angelscript.lib Is there some kind of system lib I'm not linking (I have the latest WIP of angelscript btw)?
  5. I'm not sure how this works. I want to make a struct in angelscript that I already registered. Then I want to call a function in angelscript to initialize the struct. So here is what I want to do: void initObjTable(ObjTable *&t) { t->img = 0; t->frames = 0; t->AI = 0; t->dir = 0; t->freq = 0; t->downTimeMax = 0; t->downTime = 0; t->depthAdjust = 0; t->bubbleAlways = 0; t->lightSource = 0; t->lightStrength = 0; t->sucktion = 0; t->anchorWall = 0; t->anchorWallDir = 0; t->dieScript = 0; t->visibleScript = 0; return; } bool setObjTable() { ObjTable t; initObjTable(&t); t.img = 0; t.frames = GetFrames(t.img); return false; } The building fails when I call initObjTable(&t); But, if I take out the &t or the *&t in the objTable function, it works fine, so I know it isn't anything else causing the problem. I'm wondering if doing this kind of thing is possible in the scripts, but if not, how can I do it by passing a struct to the host app and then having the host app pass back the struct to angelscript?
  6. Well, I would use timescaling, but I can't figure out how to check for collision using that method. Say I have a bubble. The last time the game updated was a long time ago becuase we are using an old pc. So the bubble's movement will be multiplied by a lot. Because it moves so far skipping so many pixels, the bubble skips through walls like they weren't even there. How can I prevent this? I've seen something called a sweep test, but it seemed overly complicated for the 2d style game I am trying to make. Is there any other way to do this? Quote: He probably disagree in the the don't waste CPU cycles twiddling your thumbs and don't look stupid trying to lock the FPS sort of way. Whoah! Settle down. No need to call names. :)
  7. I tried modifying Seriema's code so that it runs in a frame by frame basis: while { call FrameFunc; } where that loop isn't interupted by the frames per second loop. This code should run every frame of my game loop. When the code is done for the frame, the game goes to the state manager. From each state it checks if timer->canRender == true. I tried to unwrap everything, but it isn't working. Anybody? // timer struct: struct Timing { Timing::Timing(); bool canRender; int timeState; DWORD dwTick; float SPFLock, time; }; Timing::Timing() { dwTick = GetTickCount(); SPFLock = 1.0f / 1.0f; timeState = 0; time = 0.0f; } // game code: if( DWORD dwDelta = GetTickCount() - timer->dwTick) { if (timer->timeState == 0) { float fDelta = 0.001f * dwDelta; timer->canRender = false; timer->timeState = 1; timer->dwTick = GetTickCount(); timer->time += fDelta; } if (timer->timeState == 1) { if (timer->time < timer->SPFLock) { timer->time -= timer->SPFLock; timer->canRender = false; } else { timer->canRender = true; timer->timeState = 0; } } } else timer->canRender = true; [Edited by - Ped Xing on June 30, 2004 5:18:45 PM]
  8. Can any show me how to maintain a fixed frames per second? I don't want to scale variables using a delta type system and pixels per second. I want to do something like this: setFrameRate(70); while (playing) { while (update_timer) { update_game(); } render_game(); while (extra_time); } This would update the game at a fixed rate and if time allowed it, render the game. My question is, how could I code a system like this? I've been trying to code a system like this for a couple weeks, and I have had no luck.