This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
31
Function Peer Review / move_towards_point + move_snap
« on: October 24, 2010, 08:23:45 pm »
Randomly found a function that was needed.
Here you go.
Haven't tested it, but I'm sure that it can easily be modified to work.
EDIT: And I tested it and it didn't work. Josh, make it work.
Here you go.
Code: [Select]
void move_towards_point(double x, double y, double spd)
{
double angle = atan2(y - ((object_planar*)enigma::instance_event_iterator->inst)->y,
x - ((object_planar*)enigma::instance_event_iterator->inst)->x);
((object_planar*)enigma::instance_event_iterator->inst)->x += cos(angle) * speed;
((object_planar*)enigma::instance_event_iterator->inst)->y -= sin(angle) * speed;
}
void move_snap(double x, double y)
{
((object_planar*)enigma::instance_event_iterator->inst)->x = round(((object_planar*)enigma::instance_event_iterator->inst)->x * x) / x;
((object_planar*)enigma::instance_event_iterator->inst)->y = round(((object_planar*)enigma::instance_event_iterator->inst)->y * y) / y;
}
Haven't tested it, but I'm sure that it can easily be modified to work.
EDIT: And I tested it and it didn't work. Josh, make it work.
32
Proposals / Decrease Code Size?
« on: October 20, 2010, 02:33:38 pm »
Random suggestion, but you could do what jQuery, Google, and a few other sites do for code.
You can offer development and generic versions of the source codes. The development version includes comments and spaces, whereas that is all removed from the other version, to save space, download time, and compile time.
I dunno, but it seems like it might be a good idea. Probably doesn't make sense to do it now, though.
Spaces and tabs take up a surprising amount of space.
You can offer development and generic versions of the source codes. The development version includes comments and spaces, whereas that is all removed from the other version, to save space, download time, and compile time.
I dunno, but it seems like it might be a good idea. Probably doesn't make sense to do it now, though.
Spaces and tabs take up a surprising amount of space.
33
Function Peer Review / Trimming
« on: September 09, 2010, 03:35:56 pm »
I was bored, and I had these lying around. Dunno if anyone would use them for a game, but hey, whatever.
string string_trim_leading(string str) - Trims whitespace at the beginning of lines
string string_trim_trailing(string str) - Trims whitespace at the end of lines
string string_trim_lines(string str) - Trims whitespace around lines
string string_trim_begin(string str) - Trims whitespace at the beginning of a string
string string_trim_end(string str) - Trims whitespace at the end of a string
string string_trim_both(string str) - Trims whitespace on both sides of a string
string string_trim_chars(string str, string chars) - Trims whitespace around certain characters
bool string_empty(string str) - Returns true if a string consists only of whitespace
Code: [Select]
string string_trim_leading(string str)
{
for (size_t i=0;i<str.length();i++)
{
if ((str[i]=='\n' || i==0) && isspace(str[i+1]) && str[i+1]!='\n')
{
str.erase(str.begin()+(--i)+2);
}
}
return str;
}
string string_trim_trailing(string str)
{
for (size_t i=0;i<str.length();i++)
{
if ((str[i]=='\n' || i==str.length()-1) && isspace(str[i-1]) && str[i-1]!='\n')
{
str.erase(str.begin()+(--i));
}
}
return str;
}
inline string string_trim_lines(string str) { return string_trim_leading(string_trim_trailing(str)); }
string string_trim_begin(string str)
{
if (str.length()>0)
{
while (isspace(str[0]))
{
str.erase(str.begin());
if (str.length()==0)
{
break;
}
}
}
return str;
}
string string_trim_end(string str)
{
if (str.length()>0)
{
while (isspace(str[str.length()-1]))
{
str.erase(str.length()-1,1);
if (str.length()==0)
{
break;
}
}
}
return str;
}
inline string string_trim_both(string str) { return string_trim_begin(string_trim_end(str)); }
string string_trim_chars(string str, string chars)
{
for (size_t i=0;i<str.length();i++)
{
for (size_t j=0;j<chars.length();j++)
{
if (str[i]==chars[j])
{
if (i>0)
{
while (isspace(str[i-1]))
{
str.erase(str.begin()+(--i));
}
}
if (i<str.length()-1)
{
while (isspace(str[i+1]))
{
str.erase(str.begin()+i+1);
}
}
}
}
}
return str;
}
inline bool string_empty(string str) { return string_trim_both(str)==""; }
string string_trim_leading(string str) - Trims whitespace at the beginning of lines
string string_trim_trailing(string str) - Trims whitespace at the end of lines
string string_trim_lines(string str) - Trims whitespace around lines
string string_trim_begin(string str) - Trims whitespace at the beginning of a string
string string_trim_end(string str) - Trims whitespace at the end of a string
string string_trim_both(string str) - Trims whitespace on both sides of a string
string string_trim_chars(string str, string chars) - Trims whitespace around certain characters
bool string_empty(string str) - Returns true if a string consists only of whitespace
35
Proposals / GM Function Implementations
« on: August 25, 2010, 10:37:28 am »
Considering how it's been asked, I figured that I'd make a topic about it. If a function is not implemented, you can post a C++ or GML (preferably C++) equivalent here for others to use. Before you do, please check out the latest version of ENIGMA from the SVN to ensure that it is not already implemented. If it shows up in the list under ENIGMA > Keywords > Functions, try running "grep function_name $(find)" in the ENIGMA directory (bash-only). It might take a few seconds, but once it's done, it will direct you to the file that the function is defined in.
Anything that involves actual game resources (sprites, sounds, etc.) shouldn't be worked on and the actual ENIGMA devs should handle it. But other than that, go ahead. Anything that isn't actually implemented in GM but might be useful should also be posted.
Note that the current graphics/audio systems run on OpenGL/OpenAL and that the current window managers are a giant mess because we have six completely different versions that will be used. Eventually, Direct3D/DirectAudio will likely be implemented for Windows simply because Intel sucks cocks.
Anything that involves actual game resources (sprites, sounds, etc.) shouldn't be worked on and the actual ENIGMA devs should handle it. But other than that, go ahead. Anything that isn't actually implemented in GM but might be useful should also be posted.
Note that the current graphics/audio systems run on OpenGL/OpenAL and that the current window managers are a giant mess because we have six completely different versions that will be used. Eventually, Direct3D/DirectAudio will likely be implemented for Windows simply because Intel sucks cocks.
36
General ENIGMA / Someone should
« on: August 09, 2010, 08:21:44 pm »
Make icons for GM5-8 projects (plus an ENIGMA project in the case that it ever gets its own format) so that they can be used for type associations.
Preferably the way that Tango does it, with 16x16, 22x22 (with a 1px transparent border for 24x24), 32x32, and 48x48 (SVG) icons.
I dunno how to do it in Windows (I'm sure that someone here does), but I'll make the config for Linux.
Also, first person to take a the Windows .txt icon and smack a GM logo on it gets shot.
Preferably the way that Tango does it, with 16x16, 22x22 (with a 1px transparent border for 24x24), 32x32, and 48x48 (SVG) icons.
I dunno how to do it in Windows (I'm sure that someone here does), but I'll make the config for Linux.
Also, first person to take a the Windows .txt icon and smack a GM logo on it gets shot.
37
General ENIGMA / ENIGMA Installer for Linux
« on: August 04, 2010, 03:52:06 pm »Code: [Select]
#!/bin/bash
startdir=$(pwd)
_svntrunk=https://enigma-dev.svn.sourceforge.net/svnroot/enigma-dev/
_svnmod=enigma-dev
svn co $_svntrunk
mkdir -p $startdir/pkg/opt/enigma
cp -r $startdir/$_svnmod/trunk -T $startdir/pkg/opt/enigma
cd $startdir/pkg/opt/enigma/CompilerSource
mkdir -p $startdir/pkg/usr/sbin
mkdir -p $startdir/pkg/usr/share/pixmaps
mkdir -p $startdir/pkg/usr/share/applications
mkdir -p $startdir/pkg/usr/share/mime/packages
mv $startdir/pkg/opt/enigma/enigma.svg $startdir/pkg/usr/share/pixmaps
mv $startdir/pkg/opt/enigma/enigma.desktop $startdir/pkg/usr/share/applications
mv $startdir/pkg/opt/enigma/enigma.xml $startdir/pkg/usr/share/mime/packages
mv $startdir/pkg/opt/enigma/enigma $startdir/pkg/usr/sbin
chmod -R 777 $startdir/pkg/opt/enigma
chmod 755 $startdir/pkg/usr/sbin/enigma
chmod 544 $startdir/pkg/usr/share/applications/enigma.desktop $startdir/pkg/usr/share/mime/packages/enigma.xml
make linux
rm -rf $(find $startdir/pkg | grep 'svn$')
rm -r $startdir/pkg/opt/enigma/CompilerSource/.eobjs
This is taken from a PKGBUILD that I made for Arch. It can be applied to install ENIGMA on Ubuntu and other distros. The original PKGBUILD can be found here.
To install this, run sudo cp pkg -T /. Once this is done, run update-mime-database /usr/share/mime to update the MIME database. In GNOME, run nautilus -q to make the changes take effect immediately, however, a safer way would be to log off and then back on.
This will add a link to ENIGMA (LGM, but it's called ENIGMA) in the applications menu as well as adding MIME association for Game Maker executables (identification even without an extension) and also the ability to run "enigma *file*" from a terminal to open LGM.
If anyone feels like making icons for GM projects, I'll add that as well.
Also, [tt] bbcodes are broken; fix them.
38
Issues Help Desk / screw angle()
« on: July 24, 2010, 01:21:49 pm »Code: [Select]
inline int makerange(double value, double min, double max) { return fmod(value,abs(max-min))+std::min(min,max); }
How can I make this work for negative numbers without using while?
39
Issues Help Desk / GL Lighting
« on: July 19, 2010, 07:35:57 pm »
I could spend several hours looking across the internet to find an answer to my question, but maybe someone here knows an answer.
http://dl.dropbox.com/u/6125077/other/gltest.tar.gz
Why isn't the lighting working?
Is it SFML, or is my code wrong?
http://dl.dropbox.com/u/6125077/other/gltest.tar.gz
Why isn't the lighting working?
Is it SFML, or is my code wrong?
40
Off-Topic / Help coding something...
« on: July 02, 2010, 12:25:43 pm »
Remember that mixed type class that I was working on a long time ago?
Here's my scenario:
- The value for the variable is stored in a void pointer with an integer to decide which type is currently stored. When the variable is typecasted, the value is casted the the proper type using a function (returning an error if it can't be).
- To cast types, a 2-dimensional array of "cast functions" is provided. Each type that is supported is given an ID, and cast_functions[from][to] will provide the proper function to cast a void pointer from one type to another. Invalid IDs, etc. return errors.
Here's the problem:
- For operators, you don't know what the type is, and thus, you can't exactly add two types together. If you're adding mixed to a different type, you can use that type, but mixed and mixed? It can't be done.
The only solution that I can think of for this is to create an array of functions for each operation, and that would result in a massive size; is there anyone with other suggestions for this?
Here's my scenario:
- The value for the variable is stored in a void pointer with an integer to decide which type is currently stored. When the variable is typecasted, the value is casted the the proper type using a function (returning an error if it can't be).
- To cast types, a 2-dimensional array of "cast functions" is provided. Each type that is supported is given an ID, and cast_functions[from][to] will provide the proper function to cast a void pointer from one type to another. Invalid IDs, etc. return errors.
Here's the problem:
- For operators, you don't know what the type is, and thus, you can't exactly add two types together. If you're adding mixed to a different type, you can use that type, but mixed and mixed? It can't be done.
The only solution that I can think of for this is to create an array of functions for each operation, and that would result in a massive size; is there anyone with other suggestions for this?
43
Off-Topic / And you said that cplusplus.com couldn't explain pointers
« on: April 14, 2010, 08:49:12 pm »
Try reading the GTK+ documentation, sometime.
They can't even explain how to create a button.
They can't even explain how to create a button.
45
Proposals / Idea for var
« on: March 27, 2010, 10:10:56 pm »
This is an idea that I had a while ago, and I'm assuming that it will be a lot faster than var:
mixed.hpp
types.hpp (has a lot of stuff that is not required for the above)
Unsigned char and char are treated as separate types to dictate which should be displayed as a character and which should be displayed as a number.
I use types.hpp for a lot, which is why it has loads of comments (mixed.hpp would have the same thing but I'm lazy right now). I just made mixed.hpp in about ten minutes.
tl;dr for the code: it stores void *value and uint8_t type, the void pointer storing the value of the type, and the integer to decide which type that it is, as opposed to creating a separate value for double and string within a structure and returning whichever one depending on which is requested.
mixed.hpp
types.hpp (has a lot of stuff that is not required for the above)
Unsigned char and char are treated as separate types to dictate which should be displayed as a character and which should be displayed as a number.
I use types.hpp for a lot, which is why it has loads of comments (mixed.hpp would have the same thing but I'm lazy right now). I just made mixed.hpp in about ten minutes.
tl;dr for the code: it stores void *value and uint8_t type, the void pointer storing the value of the type, and the integer to decide which type that it is, as opposed to creating a separate value for double and string within a structure and returning whichever one depending on which is requested.