Help - Search - Members - Calendar
Full Version: Minecraft Engine Preview *scraped*
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS2-Submissions
dotsonface
Minecraft Engine Preview
This script has been stopped due to issues with memory.
Rpg Maker VX simply can't handle this script.


The progress on this is coming very well, I put this together in 1 day so it doesn't have much for features.

Features:
Saving and Loading: The map will be saved and can be loaded using a script code.
Minecraft Texture Pack Compatibility: Use minecraft texture packs in the game! I got it running just fine! Only 32x32 image files though.
Map Scrolling: You can scroll the map using the arrow keys
Map Generator: This doesn't put any variety on the maps... yet. Soon it will vary the map a lot in Version 0.2.
Crash Reporter: This is a built in crash reporter, when the game crashes there will be a log file that you can send to me so I know exactly what has happened to the game, don't worry, it isn't detailed that much.
2D Engine: It uses the tiles from the Minecraft Texture pack to create a map, I plan on making a 3D engine sometime.

There are two scripts that need to be put in the game for it to work.

Snapshot


MapClass
==============================================================
============
====
# Version 0.1 Ruby Syntax
#==============================================================================
# Requirements:
# Dotsonface Default 2D Map Engine Version 0.1 or Greater
# Minecraft Texture Pack (not default) installed in System Folder 32x32 .png
#==============================================================================
# Not Compatible With:
# Dotsonface Default 3D Map Engine Version 0.1 or Greater
# Minecraft Texture Pack with a higher or lower resolution than 32x32 or with
# an extension other than .png.
#==============================================================================
# I purposely made this not compatible with .png files to prevent low image
# quality.
#------------------------------------------------------------------------------
# To set up or customize your own 2D engine, you must have the class named
# MapEngine2D.
#==============================================================================
# This script only works in 2D Engine mode... 3D may be coming later.
# For the current moment this is ONLY a preview. Not the actually thing.
# Seeds don't do anything in this script at the moment.
# REQUIRES Dotsonface Default 2D Map Engine Version 0.1 or Greater!
#==============================================================================
# Script Call:
# $scene = MapClass.new(x,y,z,load?,seed,mapname,mode,y limit,x limit,z limit)
# Example:
# $scene = MapClass.new(0,3,0,false,200,"FlatPlains","2D",126,100,100)
#==============================================================================
# Other Features:
# The map saves itself and can be loaded by setting the name exactly as you had
# it before and setting m to true.
# You can use the arrow keys to move the map around.
# It can report errors into a English readable format.
#==============================================================================
# If you run into any error, send me your Log file inside the Log Data folder.
#==============================================================================
# INSTRUCTIONS!
#
# 1) Create the following folders
# Log Data
# Map
# (inside the map folder)
# 2D
# 3D
# CrashReporter
#==>
# 2) Import the texture pack, you can even use a texture pack from any minecraft
# site as long as it is 32x32 per tile. SYSTEM FOLDER
#==>
# 3) Plug into a test game and press Run!
#==============================================================================

class MapClass < Scene_Base

def initialize(x=0,y=3,z=0,m=false,s=rand(10000000),name="nullname",mode="2D",ylim=126,xlim=100,zlim=100)
$name = name
$mode = mode
$p_x = x
$p_y = y
$xlim = xlim
Graphics.brightness = 255
$ylim = ylim
$zlim = zlim
$p_z = z
$seed = s
$saveload = m
$map_name = name
if m == false
if $mode == "3D"
if $log == nil
$log = []
end
$log.push("Map Mode: 3D Engine")
if MapEngine3D == nil
$log.push("There is no 3D engine installed... reporting error.")
report_error
end
generate_map(s)
elsif $mode == "2D"
if $log == nil
$log = []
end
$log.push("Map Mode: 2D Engine")
if MapEngine2D == nil
$log.push("There is no 2D engine installed... reporting error.")
report_error
end
generate_map2d(s)
end

else
load_map
end
end

def report_error
time = Time.new
file = File.open("CrashReporter/Failure #{time.month} #{time.day}.txt", "wb")
Marshal.dump($log, file)
file.close
print "A critical error has occurred, closing program."
unless $map == nil
dump_map
end
exit
end

def update
# @player.update
# @map.update
dump_map
Graphics.update
@Engine.update
Input.update
if Input.trigger?(Input::DOWN)
@Engine.y -= 32
elsif Input.trigger?(Input::RIGHT)
@Engine.x += 32
elsif Input.trigger?(Input::LEFT)
@Engine.x -= 32
elsif Input.trigger?(Input::UP)
@Engine.y += 32
end
time = Time.new
if $log == nil
$log = []
end
$log.push("#{time.hour}:#{time.min}:#{time.sec} - Update Process.")
file = File.open("Log Data/#{time.month} #{time.day}.txt", "wb")
Marshal.dump($log, file)
file.close
end

def dispose
@Engine.dispose
dump_map
$map = nil
end

def dump_map
if $map==nil
time = Time.new
file = File.open("CrashReport #{time.month} #{time.day}", "wb")
Marshal.dump("Error Code: #{rand(10000000)} could not dump information with map that doesn't exist.", file)
file.close
print "An error has occurred, could not dump information from non-existant variable."
$scene = Scene_Title.new
else
if $mode == "2D"
file = File.open("Map/2D/#{$name}.txt", "wb")
elsif $mode == "3D"
file = File.open("Map/3D/#{$name}.txt", "wb")
end
Marshal.dump($map, file)
end
end

def load_map
$map = []
file = File.open("Data/Map#{$name}.rvdata", "rb")
$map = Marshal.load(file)
if $map.size > 600
print "Success"
print $map
elsif $map.size <= 0
print "Failure"
end
#exit
if $mode == "2D"
@Engine = MapEngine2D.new("Default", ylim, xlim, $map)
elsif $mode == "3D"
@Engine = MapEngine3D.new("Default", ylim, xlim, zlim, $map)
end
end

def generate_map(s)
if $map == nil
$map = []
end
$x = 0
$y = 0
$z = 0
$blockid = 0
loop {
if $y == 6
if $z == 99
if $x == 99
break
else
$x += 1
$z = 0
$y = 0
end
else
$z += 1
$y = 0
end
else
$y += 1
end

if $y == 0
$blockid = 0
elsif $y == 1
$blockid = 1
elsif $y == 2
$blockid = 1
elsif $y == 3
if rand(5) == 0
$blockid = rand(2)-1
elsif rand(5) == 1
$blockid = 0
elsif rand(5) == 2
$blockid = 1
elsif rand(5) == 3
$blockid = 1
elsif rand(5) == 4
$blockid = rand(2)-1
elsif rand(5) == 5
$blockid = 0
end
elsif $y == 4
$blockid = 0
elsif $y == 5
$blockid = 0
elsif $y == 6
$blockid = 0
end

$map.push("#{$x} #{$y} #{$z} #{$blockid}") # X Y Z BLOCKID
}
if $map.size >= 600
dump_map
print "You have done it!"
exit
else
dump_map
print "You have done it"
exit
end
dump_map
if $mode == "2D"
@Engine = MapEngine2D.new("Default", ylim, xlim, $map)
elsif $mode == "3D"
@Engine = MapEngine3D.new("Default", ylim, xlim, zlim, $map)
end
$game_variables[1] = $map
end

def generate_map2d(s)
if $map == nil
$map = []
end
$x = 0
$y = 0
$blockid = 0
loop {
if $y == 125
if $x == 99
break
else
$x += 1
$y = 0
end
else
$y += 1
end

if $y == 0 or $y == 1 or $y == 2 or $y == 3
$blockid = 0
elsif $y == 4
$blockid = 3
elsif $y >= 5
$blockid = 2
end

$map.push($blockid)
}
dump_map
if $mode == "2D"
@Engine = MapEngine2D.new($ylim, $xlim, $map)
end
$game_variables = Game_Variables.new
$game_variables[1] = $map

end

end


Dotsonface Default 2D Engine Version 0.1
#=========================================================================
=====
# MapClass
# Open Source free for use unless you intend to make money with this.
# Made originally by: Dotsonface
#==============================================================================
# Version 0.1 Ruby Syntax
#==============================================================================
# Requirements:
# Dotsonface Default MapClass Extension Version 0.1 or Greater
# Minecraft Texture Pack (not default) installed in System Folder 32x32 .png
#==============================================================================
# Not Compatible With:
# Dotsonface Default 3D Map Engine Version 0.1 or Greater
# Minecraft Texture Pack with a higher or lower resolution than 32x32 or with
# an extension other than .png.
#==============================================================================
# It is highly recommended that you keep this engine the same version as the
# default Minecraft Based MapClass Extension.
#==============================================================================
# Version History
# 10/6/11 - Made Version 0.1
# Draws blocks in a icon like fashion.
#==============================================================================
# Edited Classes: Window_Base
# Line: 29-37
# Added Classes: MapEngine2D
# Version 0.1 Preview
#==============================================================================


class Window_Base < Window

def draw_block(icon_index, x, y, enabled = true)
bitmap = Cache.system("Default")
rect = Rect.new(icon_index % 16 * 32, icon_index / 16 * 32, 32, 32)
self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
end

end

class MapEngine2D < Window_Base

def initialize(xlim, ylim, data)
super(-320,0,2000,2000)
self.windowskin = nil
$xlim = ylim
$ylim = xlim
$data = data
draw_map
end

def draw_map
$renderblock1 = -1
$renderblock2 = 0
$renderblock3 = -1
loop {
$renderblock1 += 1
$renderblock3 += 1
if $renderblock1 >= $xlim
if $renderblock2 >= $ylim
break
else
$renderblock2 += 1
$renderblock1 = -1
end
end
if $data[$renderblock1] == 0
else
draw_block($data[$renderblock1], $renderblock2*32, $renderblock1*32, true)
end }
end

end


This is open source, you can modify this in any way you want, but if you modify ANY code that wasn't listed in the instructions I wont take your error reports.

Here is a texture pack I used:
Texture pack


I am the full author of this script and made this in a day!

WARNING: Setting the maximum X and Y over 1000 could cause serious memory problems to your computer! Do NOT try this until I can find some requirements. I have already crashed my computer several times by messing with this. Memory consumption should be around 25 KB.
Night5h4d3
Scripts should go in their respective submission forums.

Moving to rgss2 script submissions
~Night5h4d3
dotsonface
Okay, thank you NightShade biggrin.gif
luigi400000
Ha! This is amazing! I didn't think it'd be that good! Keep up the good work!
ASCIIgod
so exactly what this script do? the looks too it it doesnt deserve attention
-dah0rst-
I see like a thousand of global variables oO
Btw, I once tried to do simple 3D on VX- forget it wink.gif VX is way to high level for good graphic algorithms^^

Oh fuck, I'm on critizising mode today Oo

Maybe you should work with some more datastructures to avoid those global variables (You know, memory usage, counter reference and friends wink.gif )
dotsonface
Here is a brief explanation of the system that is going to be used.
First of all, yes there is going to be global variables, I have been testing how big the maps can get before the game crashes.
The variable I am using is called $map, it is just an array that keeps thousands of block ID's. I have tested this in both 3D and 2D.
I can't seem to get 3D working without the game freezing and locking. 2D works great! I am going to update the script soon with an updated save system. The save system is going to include the X limitations and the Y limitations of the map. That way when the map is loaded the game will already know what dimensions to put when reading the array of block Ids. I figured out a bunch of math to use with this and soon there will be a map editor as well. So now this script is going to edge closer to become potential. I will be posting more screenshots and I have been working on getting a sky to work.
ASCIIgod
as i said it doesnt worth a bucket of craps.... just scrap thos project man and save your dignity for your most epic fail
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.