Jump to content
  • Advertisement

Michael Marchesan

  • Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About Michael Marchesan

  • Rank

Personal Information


  • Github
  • Steam

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Michael Marchesan

    Organizing objects for collisions - hobby game engine

    My idea is to exactly avoid that. Every object would have its pointer to collider list of things it can collide with and function for what to do upon collision. With objects you don't interact with, you simply don't have a dedicated list. if class A can collide with class B, class B with C, i only have a list of B items and a list of C items. A will check collision for the list of B items, B will check for the list of C items, C won't do any check. Plus no collider list of A items exist. This also solves the A checks each B and does what it has to do. B doesn't have to check A. The engine step would be: for each object for each collider list IN that object (so not every collider list of the engine) for each element in that list if collision then call function associated with that list in this object I further elaborated he idea, my problem now is storing somewhere lists of pointers to different classes. I guess i'll go for the dynamic cast, but tbh it seems weird. After all the compiler *could* know at compile time the type of each collider list.
  2. Hi, as some here i'm working on my own, little and insignificant game engine based on sfml. It's more as a general training than anything else. I've got to a decent point, here's what i already have if you dont want to go straight to the quesiton: Now, each Object has a private "move" method that is called each step for movement. I then wanted to give a simple interface for collisions, but its getting difficult to do. (collision itself is already ready). Ideally i wanted an actual game to define its own objects as children of Object, overriding the desired methods and adding any variable the user needs. However this goes in conflict with the way i wanted to structure collision. My idea for collision was: Add a list of "collider list" to game engine. Each "collider list" is a list of objects. When you create an object that will need to be checked for collision with by something, you add it to a collider list (for example i could have a collider list holding all walls). When i create a moving object which must perform a specific action on collision with a specific collider list, i add a pointer to that collider list to that object's "collisions list", and a function pointer to a function that takes (here comes the difficult part) Object* other as argument? While the game is running, when applying movement to a specific object a, the engine internally checks if there's a collision for each object b of each "collider list" c inside a's "collisions list", and for each b which collides, call the function associated with that c inside a. Simplified base classes to follow this sequence (c++ looking pseudocode written on the fly, i might have missed something and don't look at memory management or private/public things, it's not actual code i'm using): The problem is i can only have Object* as an argument for collisions, and the user should instead be able to access the variables he set on his class that inherits from Object. Also even if i knew (and i dont) all the classes that a game based on the engine was going to make, i wouldn't be able to put the functions in that list, because the list specifies std::function<void(Object*, Object*)>, and not std::function<void(Ball*, Wall*)> Example: class Wall : public Object { bool sticky = false; } //sitcky is needed to explain the problem i have class Ball : public Object{} ... Collider_list* walls = Engine.create_collider_list(); Wall* tmp = nullptr; for(size_t i=0; i<10; i++) { //create at {x, y} coordinates tmp = Engine.create(new Wall({i, 0})); walls.insert(tmp); } tmp->sticky = true; //here's a variable specific to Wall, not present in Object, that Ball will need when it handles the collision. Ball* ball = Engine.create(new Ball({30, 30}); ball.add_collision(walls, /*some bouncing function that stops ball's movement if the wall has sticky set to bool*/); I'm not sure if it's possible to work around this through some template metaprogramming. I never dug into that, and if it's possible i'd gladly take some advices for that. The other option that came to my mind (which solves everything but i dont like), is the following: A game actually uses Object directly, no inheritance with virtual functions overriding etcc. Instead Object will have a function pointer for all custom events that previously were virtual (input, step, etcc), and a map string-to-float. The user will always deal with Object, and "defining a new class" like a Ball would consist in creating a new instance of Object and assigning it a defined set of functions and pseudo-variables in the map. Assuming the user knows what he's doing it's perfect, but the result is a sadly javascript-object feeling, which i totally dislike, with no safety nor type checks, where anything can be anything and you have to manually keep track of what is what. Yeah it would work, but yeah i'd prefer solutions that don't make c++ become javashit javascript for the rest of the program. So, can templates do the magic?
  3. Greetings, in the past the first time i got into shadows i made simple hard shadows in Game Maker Studio calculated on the CPU side, with a single light source and only squares in the map. However i get that calculating shadows each frame (not each step in a fixed timestep with dynamic fps loop) is way more costy than a draw function should be. The better way to do that would be making the GPU do all that math, which should be exactly what the gpu is meant for. However i'm having issues, lots of issues. I'm using SFML, and i know how to load and apply a shader on sfml, that's super easy. What i dont know is… what shader? I found exactly what i need in shadertoy, but now? How do i "put it" in my C++ project and make it work? What is CPU side and what should be in the shader? What do i pass to that shader? Lights cooridnates list, polygons? I'm kinda lost, i've always programmed only on the cpu side...
  4. Michael Marchesan

    Any alternatives to photoshop?

    If you need pixel-images editing Paint.net is honestly amazing. The only really huge difference is text cannot be changed once you deselect it, as it becomes regular pixels instead of remaining an object. In future they plan solving that if i recall correctly. If you need vector-images editing there's inkscape although i'm not deep enough into vector art to judge its quality.
  5. Michael Marchesan

    Ideas for RTS resource generation?

    You can look at how Age of Empires 3 or Age of Mythology custom random map scripts define a map to get an idea. Basically instead of generating a totally random map, you define how some areas should overall be, and then put all the areas together. You can download some community-made scripts from these links: AoE3 AoM and open the scripts (xs file) with any text editor.
  6. Michael Marchesan

    Having issues adding a class method

    ouch i must have missed that part in the docs, thanks!
  7. Michael Marchesan

    C++/Linux which IDE are you using or would you recommend ?

    If you're willing to not totally ditch Microsoft and give them a try, there's a feature in Windows 10 that is so underrated most Linux users didn't even hear of it: Windows Subsystem for Linux (WSL). You can have an effectively Linux environment in Windows, without a virtual machine. You can open bash console and that's literally like being on Linux. Any command line linux software can be installed and run; gui software is not officially supported but there's still ways to run it. Then you can use Visual Studio on Windows and configure it to work with WSL. That way Visual Studio can compile with a Linux OS target and the WSL can run the compiled program; and you have all the benefits of using one of the best c++ IDEs around. If you go through the process of making gui software work under WSL you can start Windows and use Linux out of it as if you started a Linux os, but you can also run any Windows software, including Visual Studio, without any emulation happening.
  8. Michael Marchesan

    Having issues adding a class method

    Hi, i'm trying to add angelscript to my graph viewing program; the scripts should be written by the user to interact with the graph in the program itself. Both graph and nodes already exist in the program, and the script shouldn't be able to delete them or create new ones directly. However the graph should have a couple methods through which the script can do so. in C++ graph.add_node() adds a node to the graph and returns a pointer to it, graph.remove_node(node*) removes the node. graph.get_first_node() returns a pointer to the first node in the list, as starting point for algorithms. node.get_neighbour(unsigned int n) returns a pointer to the nth node connected to that node. But when i try to register any of these methods that return a pointer to a node i get errors. engine->RegisterObjectType("graph", 0, asOBJ_REF); engine->RegisterObjectType("node", 0, asOBJ_REF); engine->RegisterObjectBehaviour("graph", asBEHAVE_ADDREF, "void f()", asMETHOD(graph, AddRef), asCALL_THISCALL); engine->RegisterObjectBehaviour("graph", asBEHAVE_RELEASE, "void f()", asMETHOD(graph, ReleaseRef), asCALL_THISCALL); engine->RegisterObjectBehaviour("node", asBEHAVE_ADDREF, "void f()", asMETHOD(graph::node, AddRef), asCALL_THISCALL); engine->RegisterObjectBehaviour("node", asBEHAVE_RELEASE, "void f()", asMETHOD(graph::node, ReleaseRef), asCALL_THISCALL); engine->RegisterObjectMethod("graph", "int test()", asMETHOD(graph, test), asCALL_THISCALL); engine->RegisterObjectMethod("graph", "node* get_first_node()", asMETHOD(graph, get_first_node), asCALL_THISCALL); engine->RegisterObjectMethod("node", "int test()", asMETHOD(graph::node, test), asCALL_THISCALL); engine->RegisterGlobalProperty("graph g", g); Error: Failed in call to function 'RegisterObjectMethod' with 'graph' and 'node* get_first_node()' (Code: asINVALID_DECLARATION, -10) It does so with and without * What am i doing wrong?
  9. Michael Marchesan

    register subset of stl to angelscript

    Exactly what i was looking for, thanks!
  10. Michael Marchesan

    register subset of stl to angelscript

    Hi, is there any available prewritten code that focuses on bringing most common stl features to angelscript? I'm mostly thinking of template containers (list, vector, map, queue, stack, set ...), algorithm, string, possibly iterators. Did anyone do a comprehensive stl register .h/.cpp, is anyone working on it, or i'll be the one to do it? I whish not the last one because i found out about angelscript right now...
  • 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!