Jump to content

gamecreator

Members
  • Posts

    4,937
  • Joined

  • Last visited

Everything posted by gamecreator

  1. Thank you kennar. I'm familiar with the method you show but I'm looking for an official Leadwerks function that is compatible with at least Android. I've had issues trying non-Leadwerks functions before and them not working (here).
  2. Math::Random() always returns the same value. Does anyone know a way to seed it? I've seen it done via Lua but this should be possible via C. Below is sample code which is just the example code with a few extra lines (just float rnum as global, rnum=Math::Random() in Start and a few lines in Loop to print it). #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Vec3 camerarotation; #if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS) bool freelookmode=true; #else bool freelookmode=false; #endif float rnum; bool App::Start() { //Create a window window = Window::Create("RandomTest"); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //Create a camera camera = Camera::Create(); camera->Move(0,2,-5); //Hide the mouse cursor window->HideMouse(); std::string mapname = System::GetProperty("map","Maps/start.map"); Map::Load(mapname); //Move the mouse to the center of the screen window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2); rnum=Math::Random(); return true; } bool App::Loop() { //Close the window to end the program if (window->Closed()) return false; //Press escape to end freelook mode if (window->KeyHit(Key::Escape)) { if (!freelookmode) return false; freelookmode=false; window->ShowMouse(); } if (freelookmode) { //Keyboard movement float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.05; float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.05; camera->Move(strafe,0,move); //Get the mouse movement float sx = context->GetWidth()/2; float sy = context->GetHeight()/2; Vec3 mouseposition = window->GetMousePosition(); float dx = mouseposition.x - sx; float dy = mouseposition.y - sy; //Adjust and set the camera rotation camerarotation.x += dy / 10.0; camerarotation.y += dx / 10.0; camera->SetRotation(camerarotation); //Move the mouse to the center of the screen window->SetMousePosition(sx,sy); } Time::Update(); world->Update(); world->Render(); context->SetColor(0,0,0); context->Clear(); context->SetBlendMode(Blend::Alpha); context->SetColor(1,1,1); context->DrawText("Random number: " + String(rnum),10,10); context->Sync(false); return true; }
  3. Well, shoot. That last one was what I was looking for. Thank you. Back to coding!
  4. Thanks but I think I may have accidentally stumbled on at least a temporary workaround. I was looking through all functions and came across window->GetClientHeight(). So now... Windows GetHeight(): 768 GetClientHeight(): 740 Android GetHeight(): 736 GetClientHeight(): 736 Any idea how GetClientHeight/Width relate to all this? I know they're undocumented so I need to use with caution but it helps me debug on Windows without testing on Android (saving me time).
  5. I believe Windowed programs are short several pixels in each direction. The below is an illustration showing just the Y axis but this applies to X as well. This is created with the default code: window = Window::Create("App"); context = Context::Create(window); And the following displays the above: context->DrawText("window->GetHeight(): " + String(window->GetHeight()),5,10); context->DrawText("window->GetMousePosition().y: " + String(window->GetMousePosition().y),5,40); This matters because if you try to draw, say, a health bar at the bottom, the code would have to detect and compensate for the difference between windowed and full screen (and also from Windows and Android and probably iOS as well as the above code creates a windowed app in Windows but full-screen on mobile). I believe GetHeight/GetWidth, the maximum mouse position on screen and the maximum touch position on screen should be the same no matter what (excepting maybe a pixel for starting at 0).
  6. It was really great to have you on the Leadwerks team and with the community! Thank you for all that you've done for us, including the tutorials! I wish you well with Telltale. I'm sure it will be a great experience - they've made some great adventure games.
  7. float DistanceBetween2DPoints(Vec2 p1, Vec2 p2) { return Vec3(p1.x,p1.y,0).DistanceToPoint(Vec3(p2.x,p2.y,0)); }
  8. Shapes look great and low poly, all the better. Can already see them in games like this...
  9. I'm 99% sure it wasn't in the header but I'll look again when I get home. It's definitely not here though. Thanks! Will try this. And thanks, YouGroove, for originally suggesting it.
  10. No prob at all. I was sure it would work too but I figured there's a reason that Josh provides math functions that probably already exist in C++ and I guess compatibility is it. I'll give your latest function a shot. Thanks very much franck!
  11. Thank you franck but it looks like using sqrt breaks Android apps. That's why I asked specifically if there is a Leadwerks version of it.
  12. I was trying to find these in the documentation and then Math.h but didn't see them. Do we have a function that gets the distance between two 2D points or at least a square root function?
  13. Love that. And I mentioned this before but if possible, please make it so that we can set the strength of any effect, especially in our code. Something like SetEffect(fog, 0.5); which would enable fog at half strength. Of course you'd know the better way to implement that function but that's the idea.
  14. It's not built in yet, because it's not that high-priority, but it's fairly easy to add in the future. Interesteing. I would have guessed this to be an important feature to increase the performance of mobile devices. But maybe people design very low-poly models for mobile already that don't benefit from LODs.
  15. Regarding gamepads, I posted an example for the previous version of Leadwerks here. diedir posted one which uses Lua here. If you're only developing for Windows, you can try either. I don't know if you can get the Lua one working with other devices but worth a shot.
  16. I had an interest in dabbling in this as well but I wouldn't know where to start. Some simple examples (like for the functions) and especially a section in the Getting Started page would go a long way. But I also think that this can wait until next year as there are a lot of higher priority items on Josh's plate.
  17. Yes (that's where the original thread was posted before it was moved to this forum).
  18. Nah, that's a basic function. Any model editor has it. No harm in looking for it.
  19. More, when I update the code as this: context->DrawText("Touch down index 0: " + String(window->TouchDown(0)) + " pos: " + window->GetTouchPosition(0).ToString(),5,70); context->DrawText("Touch down index 1: " + String(window->TouchDown(1)) + " pos: " + window->GetTouchPosition(1).ToString(),5,100); while holding down the both fingers and moving both, only index 0 updates continuously. Index 1 only updates when I put my finger down after having it up, but not while dragging it across the screen. Am I doing anything wrong or are these bugs?
  20. I have the following code: context->DrawText("Touch down index 0: " + String(window->TouchDown(0)),5,0); context->DrawText("Touch down index 1: " + String(window->TouchDown(1)),5,30); It works mostly as I expect except for one situation. If I hold one finger down and then a second, they both return one. If I lift my second finger and then the first, they both return to 0. But If after holding both fingers down I lift my first finger and then the second, index 0 returns 0 but index 1 is stuck at 1. If there are no fingers touching the device, shouldn't they both be 0?
  21. Why dislike them? They help give you ideas, unify the submissions and make each tournament unique!
  22. Is there a way to generate all undocumented commands and maybe put a list of them under an Undocumented category in the Command Reference? Not sure if that makes sense but it would be nice to see a list there.
  23. I've never used that function myself so I'm curious (and for anyone else who reads this): what more is there?
  24. Have you tried http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/material/materialsetshadowmode-r257
  25. That looks sweet! Did you create the textures too? The environment is very convincing and you immediately feel like you're there. While I'm not a fan of zombie games I still would have loved to play this.
×
×
  • Create New...