• 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.

kunajk

Members
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

123 Neutral

About kunajk

  • Rank
    Newbie
  1. Hello,   I offten use only uppercase fonts. Can I save space on texture?  
  2. Hi, thanks for help :)   I don't make any comparison, becouse this is my only implementation. I am beginner with angelscript, so I dont do a rocket science :) I used shared refPointer becouse i dont want to copy string when I use operator=. Honestly I am afraid, that my implementation will be slower than ordinary std::string.  void RefString::release() const { // Decrease ref count and delete if it reaches 0 if( --(*refCount) == 0 ) { for(size_t i=0; i<clones->size(); i++) { if((*clones)[i] == this) continue; delete (*clones)[i]; } delete this->refCount; delete this->pString; delete this->clones; delete this; } } RefString& RefString::operator=(const RefString& str) { if(this->pString == str.pString) return *this; std::vector<RefString*> thisClonesCopy = *(this->clones); std::vector<RefString*> strClonesCopy = *(str.clones); sort(strClonesCopy.begin(), strClonesCopy.end()); sort(thisClonesCopy.begin(), thisClonesCopy.end()); this->clones->resize(strClonesCopy.size() + thisClonesCopy.size()); std::vector<RefString*>::iterator it = set_union(strClonesCopy.begin(), strClonesCopy.end(), thisClonesCopy.begin(), thisClonesCopy.end(), this->clones->begin()); this->clones->resize(it - this->clones->begin()); *(str.refCount) += *(this->refCount); if(this->pString) delete this->pString; if(this->refCount) delete this->refCount; if(str.clones) delete str.clones; for(size_t i=0; i<clones->size(); i++) { (*clones)[i]->pString = str.pString; (*clones)[i]->clones = this->clones; (*clones)[i]->refCount = str.refCount; } return *this; }   Best regards
  3. Thanks for reply. Im new in angelscript but I like it. I write a ref string class and it works for my test scripts. Coudl you take a look if all is correct?    #pragma once #include <string> class asIScriptEngine; class RefString { friend RefString& operator+(const RefString& str1, const RefString& str2); friend bool operator==(const RefString& lhs, const RefString& rhs); friend RefString* StringFactory(RefString& refString); friend void RegisterRefString(asIScriptEngine *engine); mutable int* refCount; std::string* pString; static asIScriptEngine* mEngine; public: RefString(); RefString(unsigned int byteLength, const char *s); RefString(const std::string& str); ~RefString(); void setString(const std::string& str) { if(pString) *pString = str; else pString = new std::string(str); } std::string* getString() { return pString; } RefString& operator=(const RefString& str); void addRef() const; void release() const; static void RegisterRefString(asIScriptEngine *engine); static void RegisterStdStringUtils(asIScriptEngine *engine); }; RefString& operator+(const RefString& str1, const RefString& str2); bool operator==(const RefString& str1, const RefString& str2);   #include "RefString.h" #include <assert.h> #include <angelscript.h> #include "..\StringUtils.h" using namespace std; asIScriptEngine* RefString::mEngine = NULL; RefString::RefString() { // Let the constructor initialize the reference counter to 1 refCount = new int(1); pString = new std::string; } RefString::RefString(unsigned int byteLength, const char *s) { // Let the constructor initialize the reference counter to 1 refCount = new int(1); pString = new std::string(s, byteLength); } RefString::RefString(const std::string& str) { refCount = new int(1); pString = new std::string(str); } RefString::~RefString() { delete refCount; delete pString; } RefString* StringFactory() { // The class constructor is initializing the reference counter to 1 RefString* stringRefCounter = new RefString(); return stringRefCounter;//->getString(); } RefString* StringFactory(RefString& refString) { (*refString.refCount)++; return &refString; } // Our string factory implementation RefString* StringFactory(unsigned int byteLength, const char *s) { RefString* stringRefCounter = new RefString(byteLength, s); return stringRefCounter;//->getString(); } void RefString::addRef() const { // Increase the reference counter (*refCount)++; } void RefString::release() const { // Decrease ref count and delete if it reaches 0 if( --(*refCount) == 0 ) delete this; } bool operator==(const RefString& str1, const RefString& str2) { return *(str1.pString) == *(str2.pString); } RefString& RefString::operator=(const RefString& str) { if(*this == str) return *this; if(this->pString) delete this->pString; str.addRef(); this->pString = str.pString; this->refCount = str.refCount; return *this; } RefString& operator+(const RefString& str1, const RefString& str2) { return *(new RefString(*(str1.pString) + *(str2.pString))); } void RefString::RegisterRefString(asIScriptEngine *engine) { RefString::mEngine = engine; int r; // Register the string type r = engine->RegisterObjectType("string", sizeof(RefString), asOBJ_REF); assert( r >= 0 ); // Registering the factory behaviour r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string@ f()", asFUNCTIONPR(StringFactory, (), RefString*), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string@ f(string@)", asFUNCTIONPR(StringFactory, (RefString&), RefString*), asCALL_CDECL); assert( r >= 0 ); // Registering the addref/release behaviours r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADDREF, "void f()", asMETHOD(RefString,addRef), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_RELEASE, "void f()", asMETHOD(RefString,release), asCALL_THISCALL); assert( r >= 0 ); // Registering the string factory r = engine->RegisterStringFactory("string@", asFUNCTIONPR(StringFactory, (unsigned int, const char*), RefString*), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterObjectMethod("string", "string &opAssign(const string &in)", asMETHODPR(RefString, operator =, (const RefString&), RefString&), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectMethod("string", "string@ opAdd(const string &in) const", asFUNCTIONPR(operator+, (const RefString&, const RefString&), RefString&), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectMethod("string", "bool opEquals(const string &in) const", asFUNCTIONPR(operator==, (const RefString &, const RefString &), bool), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); } void RefString::RegisterStdStringUtils(asIScriptEngine * engine) { int r; r = engine->RegisterGlobalFunction("void removeHtmlTags(string@, const string& in)", asFUNCTION(StringUtils::removeHtmlTags), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalFunction("void removeSections(string @, const string& in, const string& in, const string& in, bool)", asFUNCTION(StringUtils::removeSections), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalFunction("void removeWhiteCharsAtBeging(string@, const string& in)", asFUNCTION(StringUtils::removeWhiteCharsAtBeging), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalFunction("void removeWhiteCharsAtEnding(string@, const string& in)", asFUNCTION(StringUtils::removeWhiteCharsAtEnding), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalFunction("void removeMultipleEnters(string@, const string& in)", asFUNCTION(StringUtils::removeMultipleEnters), asCALL_CDECL); assert( r >= 0 ); }   void main() { print("Hello world\n"); print("AB" + "CD" + "\n"); string sr1 = "raz"; string sr2 = "dwa"; string str3("dupa\n"); print(sr1); print(sr2); print(str3); if(sr1 == sr2) print("rowne"); else print("rozne"); }
  4. Thanks for answer. Its working, but I prefer '@' befour result param, to show, that this param to show that this param will be changed(programing style only). I understand, that I cant use only @ in ref type objects? removeSections(@strToRet, str, "<--", "-->", true);
  5. Hello,  I want register function void StringUtils::removeSections( std::string* result, const std::string& html, const std::string& startStr, const std::string& endStr, bool withTags )   as script global function:   r = engine->RegisterGlobalFunction("void removeSections(string@, const string& in, const string& in, const string& in, bool)", asFUNCTION(StringUtils::removeSections), asCALL_CDECL); assert( r >= 0 );   and use it in script in that way:   string strToRet; removeSections(@strToRet, str, "<--", "-->", true); print(strToRet + "\n");   But as i undestrund, to use "string@" the string must be the ref type. So I am confused, how make string Ref and Value type at the same time.