Skip to content

Instantly share code, notes, and snippets.

View BenMakesGames's full-sized avatar

Ben Hendel-Doying BenMakesGames

View GitHub Profile

why LINQ is great

LINQ lets you manipulate collections super-easily, eliminating the need for loops and temporary variables in many cases.

here's a simple example: finding even numbers from a list of numbers, using a loop:

public List<int> FindEvenNumbers(List<int> numbers)
{
 var evenNumbers = new List();
@BenMakesGames
BenMakesGames / contrasting-color.pipe.ts
Last active March 13, 2023 15:41
Angular pipe that returns black if the given color is bright; white if it's dark. supports CSS vars.
// for Angular. a pipe that picks black if the given color is very bright, or white if it's dark. the
// threshhold and exact colors used are easily configured in the code; if you wanted to add them as
// parameters to this method, that modification should be easy enough (although for consistency in
// how you handle colors in your project, you might prefer not to give yourself the choice!)
//
// Buy Me a Coffee? :D https://ko-fi.com/A0A12KQ16
//
// example usage:
//
// <div [ngStyle]="{ 'background-color': someColor, 'color': someColor|contrastingColor }">...</div>
@BenMakesGames
BenMakesGames / random-helpers.js
Last active January 27, 2018 17:54
Random Helpers: some JS extensions to help you generate quick random content for funsies (not for use where security is a priority)
/**
* @see {@link https://gist.github.com/BenMakesGames/58c5307108b74b4995c60a7b056ab04f}
* @file These methods make no attempt to be SECURE, in terms of the sorts of concerns that cryptography might be
* worried about. They're intended to be used to quickly make FUN things, like procedurally-generated content for a
* game. If you care about generating passwords or other secure keys, do not use these methods.
* @author Ben Hendel-Doying
*/
/**
* Returns a random integer between min and max, inclusive. (The way a human might "naturally" expect.)
# by Ben Hendel-Doying
# Buy Me a Coffee? :D https://ko-fi.com/A0A12KQ16
#
# the following scripts are for RPG Maker VX Ace
#
# they allow for the automatic movement of the party between maps simply by walking
# to the edge, without the need to create ANY events on any map.
#
# BUT: it's required that all maps be only one screen in size. (it should be easy
# to remove this limitation, though I have not tried it.)
# assuming you have the MOG Character Select script installed, this script
# makes it so that selecting "New Game" from the title menu jumps directly
# into the Character Select script. once you select a character, the game
# begins.
# note that using this script renders the Character Select useless EXCEPT
# when starting a new game. calling it at any other time will have weird
# effects.
# the MOG Character Select script can be found here:
# http://atelier-rgss.com/RGSS/Menu/ACE_Menu07.html
# I did not make this script, a user named "Shaz" did, on this
# thread: http://forums.rpgmakerweb.com/index.php?/topic/9139-simple-slopes/
# I made trivial modifications, and fixed an issue where characters
# would sometimes face in weird directions when moving on stairs.
# terrain tag for stairs sloping from the bottom-left to upper-right
SLOPE_UP_TAG = 4
# terrain for stairs sloping from the top-left to bottom-right
SLOPE_DOWN_TAG = 6
=begin
with this script, pressing ESC takes you directly to the "Quit" dialog,
AND adds two new options to this dialog: Save, and Load.
useful for games without inventory or party-management, where having the
normal menu is inappropriate.
Buy Me a Coffee? :D https://ko-fi.com/A0A12KQ16
=end
class Scene_Map
=begin
Can be used to change where faces are displayed in message boxes: the left, or
the right!
To use, place a "Script" in your event BEFORE the "Message". The script should
contain either:
Window_Message.FaceOnLeft
or:
=begin
positions events with "Walk Animation" checked 8 pixels higher. for events that
represent NPCs, this places their feet closer to the center of the tile they're
standing in, rather than the bottom. this looks better on most RTP tilesets.
considerations:
* RPG Maker has "Walk Animation" on by default for ALL events. when using this
script, you should uncheck "Walk Animation" for events except those
representing NPCs. if you're adding this to an existing project, updating all
of your existing events could be a LOT of work.