Skip to content

Instantly share code, notes, and snippets.

import bpy
import os
basedir = bpy.path.abspath('//shadefoot/story_mode/ch1/trees/maple/')
bpy.ops.object.select_all(action='DESELECT')
scene = bpy.context.scene
@jedStevens
jedStevens / export_obj.py
Last active September 24, 2018 21:06
Export all objects in Blender as OBJs
import bpy
def export_all_obj(exportFolder):
objects = bpy.data.objects
for object in objects:
bpy.ops.object.select_all(action='DESELECT')
object.select = True
exportName = exportFolder + object.name + '.obj'
bpy.ops.export_scene.obj(filepath=exportName, use_selection=True)
extends KinematicBody
var FOWARD = 200
var MOVEMENT = 200
var JUMP = Vector3(0,100,0)
var RUN_SPEED = 300
var mouse_threshold = 10
var mouse_sens_dampened = 0.01
var mouse_sens = 0.01
@jedStevens
jedStevens / terrain.gd
Created July 17, 2018 14:14
Generates terrain
extends TileMap
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var height = 5
var width = 500
var loops = 6
@jedStevens
jedStevens / db_import.gd
Last active July 11, 2018 19:15
Imports a CSV file as a dictionary
func db_import(csv_file,dict_to_append,DICT_HEADERS_LIST):
#EDITED: In order to loop through keys of keys as noted in the
#EDITED section of the first post, EXTRA ARG is called DICT_HEADERS_LIST
var file = File.new()
#creates a new Class instance.
# A var will store this reference as 'file'. (file is not a string)
file.open(csv_file,file.READ)
#the file is read into memory.
# The .csv can now be manipulated with File methods.
var is_header = true
extends Node
func get_cropped_items():
# Return the items in the cropping zone,
# calculates a crop beforehand
# CROP THE ITEMS
# 1. Find the search Area
var min_x = width
@jedStevens
jedStevens / Items.gd
Created July 4, 2018 17:51
This creates recipes and stores them
extends Node
const NONE = -1
const LOG_ID = 0
const CRAFTING_TABLE_ID = 1
var CRAFTING_TABLE_RECIPE
func _ready():
var Recipe = load("res://recipe.gd")
@jedStevens
jedStevens / loader.gd
Last active July 3, 2018 14:08
This finds all of the PNGs in a folder
extends Node
var image_db = {}
func _ready():
image_db = load_pngs_from_directory("res://")
print(image_db)
func load_pngs_from_directory(path):
var files = {}
extends Line2D
var _prev_pos = Vector2()
var points_size = 100
func _ready():
set_process(true)
for i in range(points_size):
add_point(Vector2())
@jedStevens
jedStevens / skater.gd
Created April 21, 2018 17:36
LD41 Player
extends KinematicBody2D
const GRAVITY = 800.0
const PUSH_SPEED = 200
const MAX_SPEED = 500.0
const MIN_OLLIE_FORCE = 200.0
const MAX_OLLIE_FORCE = 350.0
const OLLIE_CHARGE_RATE = 600.0
var OLLIE_FORCE = 0.0