The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Advertise here

Reply
 
Thread Tools
  #1    
Old July 30th, 2011, 06:20 AM
Rai Rai's Avatar
Rai Rai
Master of everything!
 
Join Date: Aug 2010
Gender: Male

Advertise here
Well, today I announce myself here to give all of you game developers the basics of coding within Essentials. The main aim is to teach those how to make a simple window script with the day to day functions many other developers out there use to make their menus have that extra touch.
Enjoy.
Ps. If you want the code to keep reference without having to keep coming back here, I've put it in at the bottom of the thread.
Made a mistake on the code, on the last end of the code delete it, that will fix the error I made.

Spoiler:
Code:
class Window_Lesson < SpriteWindow_Base #name of the class which also takes on
  #another class name traits
  def initialize # need in all window scripts
    super(x,y,width,height) # replace inside with what size and place you want it
    @Sprites=[] # calls the sprite class, helpful on disposing all the sprites
    @Sprites["BG"] = Sprite.new # makes a new graphic
    @Sprites["BG"].x = 0 #where it is pace on X axis this case 0
    @Sprites["BG"].y = 0 #where it is place on y axis, this case 0
    @Sprites["BG"].z = 9999 # The layer picture is on
    @Sprites["BG"].bitmap=RPG::Cache.picture("whateveryouwant") #calls the sprite
#==================# Following sectino is needed to show text
    @sprites["overlay"]=Sprite.new(@viewport)
    @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
    @sprites["overlay"].z=9999999
    pbSetSystemFont(@sprites["overlay"].bitmap)
    @overlay = @sprites["overlay"].bitmap 
    @overlay.clear
    @baseColor=Color.new(12*6,12*6,12*6)
    @shadowColor=Color.new(12*14,12*14,12*14)
#==================# Section ended
    @Sprites["BG"].opacity=0 # makes transparent
      loop do #loops the following command
        Graphics.update
        Input.update
        update #calls update in a loop
        if $scene != self
          break
        end
      end
    end
  end # ends the def
  def update # defines update
#===================# Follwing needed to display text
# The first 20 shows where the text will be displayed on the X-Axis
# The second 20 shows where the text will be displayed on the Y-Axis
# If you want to add in more text later on in the code then use the following:
# But without the # infront of the line.
# textPositions.push([_INTL("Load Save1."),230,450,false,@baseColor,@shadowColor])
    textPositions=[
    [_INTL("Put what ever you want here."),20,20,false,@baseColor,@shadowColor],
    ] 
#===================#
    @frame=+1 # makes a frame count
    if Input.trigger?(Input::C) # checks if C is pressed
      p 'this works' #Pulls a window saying what's inside the ''
    end # ends def
    if @frame==50 # checks if frame is at a certain amount
      @frame=0 #changes frame count back to 0
    end
    51.times do #loops the method inside the amount of times.
      @Sprites["BG"].opacity+=5 #adds 5 onto the opacity everytime
    end #ends loop
    if Input.trigger?(Input::B)
      break # Breaks window
    end
  end
end # Ends class
#to call window use in a script command Window_Lesson.new

Last edited by Rai Rai; July 30th, 2011 at 07:10 AM.
Reply With Quote
  #2    
Old July 30th, 2011, 06:32 AM
Gmack's Avatar
Gmack
I'm back!
 
Join Date: Mar 2010
Location: Florida, USA
Gender: Male
Nature: Calm
Send a message via Windows Live Messenger to Gmack
sigh.... Finally someone makes this! Something i can relate to, not tutorials.
And best of all, it's for essentials! What a novel idea! XD
__________________
Official Blog :: http://gmacksblawg.wordpress.com/

Official Website :: http://gavinsblawg.webs.com/about
Reply With Quote
  #3    
Old July 30th, 2011, 05:06 PM
ProdigyX's Avatar
ProdigyX
Trainer
 
Join Date: Jun 2010
Location: Australia
Age: 20
Gender: Male
Nature: Brave
HAhaha very nice i see you worked over it while i was sleeping :D
Reply With Quote
  #4    
Old August 6th, 2011, 01:28 AM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
I'd have to be a downer, but there are quite a few thigs up there which would either give you a syntax error or an unwanted result. Good try though, the code is really clean. Now onto the fixes:

1. Quite an easy mistake to do with @frame. You started performing math functions without defining the variable. You first need to put @frame=0 somewhere before the update starts.

2. No text will be drawn as you forgot to place pbDrawText after textpositions have been defined, not to mention the lack of @overlay.clear to refresh the text.

3. The 51.times do command will not make the opacity go up smoothly, instead it will be filled in one frame, as there should be a pbWait(1) command before the end, that will make the whole function ladt 51 frames. Plus since it's in a loop, that function will repeat infinately, freezing your game, which is not what you want.

4. I have no idea what you put @frame in there for as it just resets when it reaches a number, don't know if that was intentional.

That's all I can see wrong/inaccurate for now.
__________________
[STOPPED][DEMO] Pokemon Blue Chrome
[DEVELOPING] S.J.Ware
[DEVELOPING] Tykanite
Reply With Quote
  #5    
Old August 6th, 2011, 06:59 AM
Rai Rai's Avatar
Rai Rai
Master of everything!
 
Join Date: Aug 2010
Gender: Male
Quote:
Originally Posted by Luka S.J. View Post
I'd have to be a downer, but there are quite a few thigs up there which would either give you a syntax error or an unwanted result. Good try though, the code is really clean. Now onto the fixes:

1. Quite an easy mistake to do with @frame. You started performing math functions without defining the variable. You first need to put @frame=0 somewhere before the update starts.

2. No text will be drawn as you forgot to place pbDrawText after textpositions have been defined, not to mention the lack of @overlay.clear to refresh the text.

3. The 51.times do command will not make the opacity go up smoothly, instead it will be filled in one frame, as there should be a pbWait(1) command before the end, that will make the whole function ladt 51 frames. Plus since it's in a loop, that function will repeat infinately, freezing your game, which is not what you want.

4. I have no idea what you put @frame in there for as it just resets when it reaches a number, don't know if that was intentional.

That's all I can see wrong/inaccurate for now.
Heh yeah, was pretty late at the time of doing it XD. I'll change up all the errors once I get back tonight. Was a 5 minute whip up type thing cause I was asked questions .
Reply With Quote
Reply
Quick Reply

Sponsored Links


Advertise here
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 08:44 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.