Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
    rey meustrus
  Sun Jan 04, 2009 5:33 am
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I sure could have used that when I was trying to build my own Tilemap class. That was a loooong time ago, though...I would have made my own, too, if I didn't feel like building the autotile INDEX was so horribly tedious. Nice work, very simple and it seems to have pretty good stability, looking at the amount of error checking.

_________________
Image


Top Top
Profile      
 

    Zeriab
  Sun Jan 04, 2009 9:04 am
Hugging Lion
User avatar
Sponsor

That's funny, I posted this script because BlueScope was messing around with the Tilemap class XD
I am glad you like, but you can't assume stability from the amount of error checking. I am using an unsafe method to check how many dimensions the table has. I know there are special cases which I should guard against.

I actually made this script over a year ago. I just forgot to post it ._.

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    Zeriab
  Tue Jan 06, 2009 10:28 pm
Hugging Lion
User avatar
Sponsor

I found a little snippet I made some time ago which can help with debugging:
Expand to see the code.


I found it in an unfinished combo system.
Unfinished combo system


*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    Zeriab
  Wed Jan 07, 2009 12:47 pm
Hugging Lion
User avatar
Sponsor

Here is an update to the StandardError extension:
Expand to see the code.


This time it appends the error to an error log if $DEBUG is true. (I.e. test run)
I like this approach since the editor appears to go to the right place like normally ^_^

*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    rey meustrus
  Wed Jan 07, 2009 7:12 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I like it. I think it would also be nice to add simple error checking to Scene_Base, and with that error log you've implemented it even makes sense to try and keep going even when you reach an error.

I'm just thinking it should be something simple like this:

Expand to see the code.


This way, errors don't destroy the program, and it's even possible to make certain errors fatal so they DO destroy the program. Just an addition to your debugging tool, I think I'll put these into my scripting bay to help debugging and make it less apt to quit.

EDIT: I've got it working, doing exactly what I want. It's a bit more complicated, but it points the script editor to the right place like the original intent. It prints all errors to the screen, but ignores them as long as an error didn't happen the last frame (indicating that the error's going to happen every frame).

Expand to see the code.


This uses some modifications to your original work:

Expand to see the code.


All that needs to be done to catch simple errors that don't occur every frame is to replace a call to main_loop with a call to error_wrapper(:main_loop) (within objects)

_________________
Image


Last edited by rey meustrus on Fri Jan 09, 2009 11:38 pm, edited 2 times in total.

Top Top
Profile      
 

    Zeriab
  Fri Jan 09, 2009 2:44 pm
Hugging Lion
User avatar
Sponsor

That is an good idea and I like your execution meustrus ^_^

I would consider only printing non-fatal errors out on the screen if $DEBUG == true.
It really depends on how you want to test the game since a silent ONLY_WRITE_TO_LOG mode gives a better feeling of how the game works. If the error message is displayed though you know when exactly it occurs. Something to consider.

Nice work anyway ^^

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    rey meustrus
  Fri Jan 09, 2009 10:31 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I like it, I'll edit the post to include that...where it says "print $!.full_message" it's changed to "print $!.full_message if $DEBUG or $!.fatal?"

_________________
Image


Top Top
Profile      
 

    BwdYeti
  Fri Jan 30, 2009 8:45 pm
Emo Halb + Emocar = :|
User avatar
Sponsor


Location: Michigan
This might be helpful even though it's kinda simple, a method that finds the angle from 0,0 to x,y and returns it (in degrees)

Expand to see the code.


Top Top
Profile      
 

    trebor777
  Fri Mar 06, 2009 1:54 am
Member

Get the X first / last items of an array !

Some people might have been used to : my_array[0,3] for example to get the first 3 items...
or my_array[-X,X] to get the last X items of an array...

Well there is actually something much simpler :

my_array.first(X)
and
my_array.last(X)

Will return a new array containing the first/last X items ^^, if you don't specify X, it'll simplify return the 1st or last item directly, not as an array.


Top Top
Profile      
 

    BwdYeti
  Fri Mar 13, 2009 1:44 am
Emo Halb + Emocar = :|
User avatar
Sponsor


Location: Michigan
Here's something I would have made earlier if I knew how. @_@
It's a C dll that (very quickly) recolors a bitmap.
http://www.bwdyeti.com/bitmap.rar

It recolors all instances of a given color with another given color. Use it with:
Expand to see the code.

Expand to see the code.


It can recolor a 640x480 bitmap every frame at 60fps while similar Ruby code using get_pixel/set_pixel would fall to 1fps .-.

I might do different things with it like recoloring by hue (something Seph suggested when I asked about recoloring in the past), but this might be helpful to someone else now.

Thanks goes to poccil for the the basis I worked from with his bitmap effects in C (viewtopic.php?f=11&t=39324)


Last edited by BwdYeti on Fri Mar 13, 2009 3:35 am, edited 1 time in total.

Top Top
Profile      
 

    e
  Fri Mar 13, 2009 1:56 am
shittybutt
User avatar



Location: Berlin
Very nice! Would it be possible to see the C source?


Top Top
Profile      
 

    BwdYeti
  Fri Mar 13, 2009 3:27 am
Emo Halb + Emocar = :|
User avatar
Sponsor


Location: Michigan
I guess, since I can hardly go "nuuuu they be stealin mah code" when I just edited poccil's.

Expand to see the code.


Also I messed up the original upload, I forgot to un-comment some lines I had removed for testing in the dll and got a few numbers backwards on the stuff in the Bitmap class. It's fixed now though.


Top Top
Profile      
 

    rey meustrus
  Fri Mar 13, 2009 5:48 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
You totally just stole BlueScope's thunder there, what with the Bitmap Recoloring script he posted earlier.

_________________
Image


Top Top
Profile      
 

    BwdYeti
  Fri Mar 13, 2009 6:22 pm
Emo Halb + Emocar = :|
User avatar
Sponsor


Location: Michigan
Oh whoops, I didn't mean to. I don't look at the release board much, I just stay in script support .-.
Well, his script does something different, and then uses get_pixel and set_pixel to set the colors. That's actually the best type of place for using this dll/script since it's just a glorified, faster get/set.


Top Top
Profile      
 

    BlueScope
  Fri Mar 13, 2009 7:33 pm
The Third Man
User avatar



Location: Germany
Just when I added alpha transparency support to mine ^^ But yeah, it appears to be a more efficient way just telling from the code, but I'll stay with my version for own uses nevertheless... especially since I created it for icon remapping XD Also, it doesn't really do the same thing, as mine's layouted to work with palettes, while yours does individual colors.

You should know I link the above post in my thread, so please let me know if you don't want that, I'll take it out then.

Keep up the good work!

_________________
Image

If you have a slightly positive memory of my Power Shift contest game,
you might be interested in this development screenshot...
More info about that soon!


Top Top
Profile      
 

    BlueScope
  Sat Mar 14, 2009 2:30 pm
The Third Man
User avatar



Location: Germany
Along with the update of my Database Flag Reader script, I'll post this little snippet in here for string conversion into integers, floats, boolean outputs, arrays, hashes or just nil.

Expand to see the code.

_________________
Image

If you have a slightly positive memory of my Power Shift contest game,
you might be interested in this development screenshot...
More info about that soon!


Top Top
Profile      
 

    rey meustrus
  Tue Mar 17, 2009 6:32 am
Master of Dark Magic
User avatar
Sponsor

Party Mascot
Nice, BlueScope. I suppose the only strangety with that is the uncertain data type which results, but that's the point isn't it? And I don't care what Firefox says, "strangety" is definitely a word!

I've got two modules that some of you might find interesting; they both deal with Win32API. The first is a Settings module, which reads the game.ini file and can read and write entries to it. It keeps a cache of the values as it reads them, and writes immediately whenever a setting is changed. The cache can be easily cleared as well:

Expand to see the code.


The second is a wrapper module for user32.dll GetSystemMetrics functions. It acts just like an initialized Win32API object (with its :call method) but I've mapped out all of the functions (up to 81). You can call it by something as simple as GSM.call(GSM::CXSCREEN) (that returns the width portion of your current screen resolution):

Expand to see the code.


If anything in there is cryptic, don't blame me (maybe some of them are my fault for trying to shorten the description to fit on one line). Microsoft's descriptions are extremely specific to the point of technical gibberish.

Oh, heh, I'd check and see what Microsoft thinks about your processor:
Expand to see the code.

_________________
Image


Top Top
Profile      
 

    BwdYeti
  Tue Mar 17, 2009 10:22 am
Emo Halb + Emocar = :|
User avatar
Sponsor


Location: Michigan
No problem BlueScope, I intended it to be used by anyone needing it. Get_pixel/set_pixel is useful but just too slow. :|

I came up with a couple new bitmap editing methods.
One takes an array of arrays of x-y locations (like [[0,0], [2,5], [8,3]]) and then changes all pixels in the bitmap at those locations to the given color.
The other... does kind of an image mask thing. Not sure what it's called exactly. Basically it takes a different bitmap as an argument, then modifies the original to be the same shape as the given one. For example, you could take an image larger than any battler you expect to encounter and put some kinda of effect in it, then have it conform to the shape of the battler it's currently displayed on top of. You could create something similar to the Pokemon stat buff/debuff effects with it.
(EDIT: Thought of another idea for it, you could create a bitmap, fill it with something like Color.new(40,40,40,192), and then fit it to a character and you have a shadow :o Just y scale its sprite a bit and maybe flip it upside down, then make it follow the character around.)

There's a few restrictions so far, the set array one is kinda slow if you use a large array because setting up the array in Ruby is slow, and the mask one needs some advanced stuff added to it (currently it always starts in the upper left and just leaves anything outside the size of the bitmap providing the shape)

The link to the dll:
http://www.bwdyeti.com/bitmap.rar

And the code to call it:
Expand to see the code.


Feel free to mention if anything doesn't seem to work right, I'm new to releasing code for others to use so I might not check things as thoroughly as I should before posting.

If I make any more methods like this I'll probably make a topic for it, since it's not really snippets anymore .-.


Top Top
Profile      
 

    rey meustrus
  Sun Mar 22, 2009 3:51 am
Master of Dark Magic
User avatar
Sponsor

Party Mascot
Don't know if I ever posted this, but it's a default value for Enumerable classes. I just added support for Procs, which allow default value to be reliant on the referenced index or hash key.

Expand to see the code.


All you have to do is call an array, $ar = [], and say $ar.default = 5 or whatever. Then, when you call $ar[1] it will return 5, even though that value wasn't defined. You can use Procs, too. If you say $ar.default = Proc.new {|index| index - 1} and you call $ar[1] it will return 0, $ar[7] will return 6...it could even be a simple Array wrapper for the Proc class if you never assign any values to the array.

_________________
Image


Top Top
Profile      
 

    Cremno
  Sat Apr 04, 2009 7:19 pm
User avatar
Member


Location: Germany
With following snippet you can use Kernel#puts and the console for easier debugging because you can read the output while testing/playing the game and you don't have toclose the annoying MessageBox.
Expand to see the code.


Returns current line:
Expand to see the code.


Current (script) section name:
Expand to see the code.


Fix for Kernel#caller:
Expand to see the code.


How to remove constants or classes:
Expand to see the code.



EDIT:

Get width and height of a PNG file:
Expand to see the code.


Downloads bits from the Internet and saves them to a file (supports HTTP and FTP):
Expand to see the code.


Top Top
Profile      
 

    MauMau
  Sun Apr 05, 2009 6:40 pm
Member

Expand to see the code.

Hey, This is a very good one!
I don't understand how it works, but i did some modifications here:
First: This is the Kernel module
Second: Why only puts, i want gets too!
Third: IT WORKS!!!!

Thank you Cremno, I always wanted gets and puts, now i got it!

Expand to see the code.


Sorry for any mistakes(English/Ruby/Win32API), MauMau


Top Top
Profile      
 

    kyonides
  Sun Apr 05, 2009 7:21 pm
Member

Well this snippet just adds 2 methods to make sure you can easily change your character / battler graphics and get them back at will via script call. Of course you still can do this by setting up some map event...

Expand to see the code.


Script Call:

$game_party.actors[0].change_graphic(0,2)

It'd transform Aluxes into a second Basil. To revert the change just call it like this...

$game_party.actors[0].get_old_graphic(0)

For VX use $game_party.members[0] instead.

The change_graphic method is a variant of the Interpreter command_322 one or more precisely it's a revised version. It doesn't just allow you to change the graphic, but it also lets you store the previous graphics names in an array temporarily.

The get_old_graphic method lets you reset the graphics at any time if deemed necessary.

BTW, it will work on both, XP and VX.

Never edit this line:

actor = $game_actors[index+1]

Or it won't work properly because the $game_actors index starts at 1 not 0 (it gets the info from $data_actors which also starts at 1).


Last edited by kyonides on Wed Mar 03, 2010 7:29 pm, edited 4 times in total.

Top Top
Profile      
 

    MauMau
  Sun Apr 05, 2009 8:45 pm
Member

Great Script!
You don't need those "return true" in the end of the method!
This is ruby, it will return the last thing anyway.
Test this:
Expand to see the code.

This works for everything in the end of a method, remember!

You can use ternary operator here, but will be a bigger line:
Expand to see the code.


MauMau


Top Top
Profile      
 

    trebor777
  Mon Apr 06, 2009 4:32 pm
Member

A cool way to dynamically do stuff :p

You can call the method of an object like this

obj.my_method

but :p what if you want my_method is unknown, i mean, that you don't know at that time which method is going to be called...
You could write statements that would call the proper method with conditions and such ...

but you could also simply generate the method name :p

let's say you have a funny old text "rpg" , you know the kind of you play in a console, that asks you what you want to do :p
usually the player would either type an ID related to the action, or would type the action name, and a method would analyse that name or the ID, and would call the method for that action...

Well ruby allows you to generate method names:p which is pretty cool
so to call the method of an object by knowing its name, it's quite easy:

obj.method( the_method_name ).call(the_arguments)

but here "the_method_name" can't be a string it must be a symbol , so to do that you just convert the string to a symbol using the "to_sym" method :p

obj.method( the_method_name.to_sym).call(the_arguments)

and voilà! :p
There you just need to play with string methods to generate the proper method names, of course, be careful that the generate name must refer to an actual existing method ( else you'll have an error)

Example in my physics engine, i'm testing collision between 2 kind of shapes, box, and circles, so we have only 3 type of collisions > box/box, box/circle & circle/circle.

So i did 3 methods to test each of those cases :p and i have one method that call the right method for the 2 shapes given....

Expand to see the code.


Look at line 7 :p ^^
I also did 3 "twin" methods with reverse names that call the 3 originals but with arguments.

It's a more useful & secure than ^^ eval and works better IMO.


Top Top
Profile      
 

    hanmac
  Mon Apr 06, 2009 4:52 pm
Member

hhihihi

object.send(method_name,*args) does the same (and it can be strings)


Top Top
Profile      
 

    trebor777
  Mon Apr 06, 2009 5:01 pm
Member

hum the online reference says that send uses symbol as well :p

the main difference is ... that "method" returns a method object, that you can call later or store in a variable,
whereas send, directly call it.

But in either case, it's still something i find really smart :p


Top Top
Profile      
 

    rey meustrus
  Mon Apr 06, 2009 10:08 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
The debug thing is great. I found an API call to get the game window to come back to the foreground immediately once the debug window is created:
Expand to see the code.

I've put the functions into a Debug module with special features:
1) Also writes to log file 'debug.log'.
2) Can :start and :stop debugging (Debug.start and Debug.stop opens/closes the console, respectively).
3) Debug.log_by_frame can be called every frame, without flooding the console with eternal messages (only prints message every one second).
Expand to see the code.

(I commented out $DEBUG because for whatever reason, probably because I'm running RMXP using RGSS202E. $TEST doesn't seem to work either)

_________________
Image


Top Top
Profile      
 

    hanmac
  Mon Apr 06, 2009 10:37 pm
Member

information:
VX has also the $DEBUG, but it isnt used.. it use $TEST


Top Top
Profile      
 

    rey meustrus
  Tue Apr 07, 2009 1:58 am
Master of Dark Magic
User avatar
Sponsor

Party Mascot
$TEST doesn't work either. Perhaps RMXP tries to set $DEBUG but the game.exe prevents it, expecting RMVX to set $TEST even though I'm not loading it from RMVX.

_________________
Image


Top Top
Profile      
 

    hanmac
  Tue Apr 07, 2009 5:31 am
Member

Expand to see the code.

so?


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next


Who is online

Users browsing this forum: No users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group