• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

meink

Virtual functions

8 posts in this topic

Virtual functions and derived classes aren''t supported in AngelScript, but I''m curious to know what sort of workarounds people are using. I''ve set my class up so you can register new derived classes in script (http://noreality.net/files/programming/astest.zip - An old proof of concept that outlines the idea), and I''ve expanded this in my engine so that you can migrate the derived class into C++, but the AS code still uses the same interface. I''ll get around to making that into an example file soon. Is this the method that most people are using? Are other people doing things like this? I was thinking about perhaps writing it up into a tutorial... - Xavier
0

Share this post


Link to post
Share on other sites
A tutorial would be excellent. If you want I can host it on my site, or if you prefer I''ll only put a link to it.

I''ll check out your solution when I get the time.

I have plans to support virtual functions natively, but it is still quite far down on the todo list.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
0

Share this post


Link to post
Share on other sites
I checked out the code. It is a very good example that clearly shows how things can be done. It is basically how I imagined AngelScript would be used.

I would put a comment in the code for Item::collidePlayer() that it can be optimized by storing the function ID in a lookup tables so that GetFunctionIDByName() doesn''t have to be called every time. Also, it might be a good idea to use some kind of pooling for contexts, so that you don''t have to create and release them each time they will be called. If each call to Prepare() uses the same stackSize the context reuses the memory it previously allocated, thus saving some more time.

I must say that I misunderstood you when you mentioned virtual functions earlier. I thought you meant that AngelScript would call virtual C++ class methods and allow polymorphism. This is what I plan to support in the future.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
0

Share this post


Link to post
Share on other sites
Yeah, I added many of those things you mentioned into my updated version (which I''ll be using for the tutorial).

For calling virtual functions from AS, I thought of having a static member function that calls this->function(). If the function was overridden in C++ it would be called, other wise the base implementation would dispatch the code to the AS defined function. Haven''t tested it though. I''ll check it out next week - I don''t have my comp for the weekend

- Xavier
0

Share this post


Link to post
Share on other sites
http://noreality.net/as-polymorphism.zip

First draft of "Polymorphism in Angelscript". I''m hoping this is actually what polymorphism is - I''m a little sketchy on definitions - otherwise I''m going to have to change the title :S

I left a few things out, which I''ve mentioned at the end. I thought it would be better to focus on the core idea, and leave the rest as an exercise for the reader (or a later tutorial...)

I''m thinking of submitting to the gamedev scripting section, and would appreciate any feedback. I''m not exactly an expert writer...

- Xavier
0

Share this post


Link to post
Share on other sites
I''ve written a precompiler which reads through your header files and generated a cpp file which registers all the variables and functions in all the classes/globally. If there''s enough demand I''ll try to make it a bit easier to use and make it available - it''s currently in a state where only I can use it.

One extra thing it does is make wrapper functions for all the ctors & dtors. If I was wanting to use polymorphism, I probably would have got the precompiler to generate non-virtual wrappers for all the virtual functions. As inheritence is still on the way, it''s unlikely that many people are useing virtual functions with AS.
0

Share this post


Link to post
Share on other sites
meink:

I read the tutorial now and I thought it was very good. I especially liked the way you solved dynamic properties for the CItem class, I hadn''t thought about that before.

Of course, at a later time AngelScript will support declaration of structs so it should no longer be necessary to do it like that.

I suggest you write what version of AngelScript you wrote the tutorial for as things may change in future versions.

AndyMan:

You know people would be interested in seeing a pre-compiler that helps with the configuration of the engine. If you are short on time (like me) maybe you could release it as it is so that others can improve upon it, or learn from it and write their own pre-compilers.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
0

Share this post


Link to post
Share on other sites
quote:
Original post by WitchLord
AndyMan:

You know people would be interested in seeing a pre-compiler that helps with the configuration of the engine. If you are short on time (like me) maybe you could release it as it is so that others can improve upon it, or learn from it and write their own pre-compilers.


Someone might look into writing a new backend for SWIG.

SWIG is a popular C++ wrapper generator that supports lots of scripting languages. It can even handle wrapping templates, etc.

No idea what is involved with writing a new backend, though.

-Wade
0

Share this post


Link to post
Share on other sites