Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 8 posts ] 
    Amy
  Thu Sep 03, 2009 6:07 pm
User avatar
Staff

Big Dumb Guy
The "Scene" style workings of RPG maker are even easier to implement into Gosu.

First you need a scene:

Expand to see the code.


We don't need to update Graphics like in RPG Maker; nor do we need to run a loop (see below).

We need our game window:

Expand to see the code.


The method initialize is called when the game is first opened. As such this can be used to call our initial scene (here, Scene_Start).

The method update is ran once per frame, automatically. Therefore, we can call our scene update methods here for convenience.

From before you'll note that super(x, y, fullscreen?) here makes the window 640x480, with no fullscreen mode.


Now all that remains is to call the script:

Expand to see the code.



Demo

Expand to see the code.



You'll noticed I added a draw_text method; this was just for ease and probably wasn't needed. Nonetheless, play around with the "demo" some and yeah.


This probably didn't need a tutorial; nonetheless if you have any problems with this post here.


Top Top
Profile      
 

    e
  Thu Sep 03, 2009 11:57 pm
shittybutt
User avatar



Location: Berlin
You don't need to make the scene a global variable; it could be a simple class variable, and then if you want to access it from outside you could just have it attr_accessor'd or something.


Top Top
Profile      
 

    Amy
  Fri Sep 04, 2009 12:18 am
User avatar
Staff

Big Dumb Guy
Ah, I never thought of it like that. I'm trying too hard to replicate what's in RGSS.


Top Top
Profile      
 

    Dahrkael
  Wed Sep 09, 2009 10:43 am
VOC@LOID #01
User avatar
Member


Location: SPain :D
button_down!!!!
<.<

the correct use is:
def button_down(id)
if id == #key
#something
end
end

Gosu have the Input in another way than rgss so you need:

Expand to see the code.


You can draw things in the update, but by default Gosu calls update to do the operations and after calls draw() to draw the things, to have all more organizated.
You dont need to use it, but is called anyway.

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Top Top
Profile      
 

    e
  Wed Sep 09, 2009 6:48 pm
shittybutt
User avatar



Location: Berlin
Don't forget about button_up; button_down will be called every tick for as long as the button's pressed, whereas button_up will only be called when it's released, so it depends on what you want to do.

button_down? is useful if you want to check in the update method if the button is currently pressed, but you don't want to actually deal with it (i.e.: check for combos or whatever).


Top Top
Profile      
 

    Dahrkael
  Wed Sep 09, 2009 10:13 pm
VOC@LOID #01
User avatar
Member


Location: SPain :D
thats not true :3

you have 3 methods

button_down()

button_up()

window_object.button_down?(id)

the two button_down(?) are different.

button_down is called every time a key is pressed and only returns true one time

.button_down? is called all the ticks while you are pressing the button, thats the difference

see it like:

button_down() -> Input.trigger?()
button_down?() -> Input.press?()

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Top Top
Profile      
 

    e
  Thu Sep 10, 2009 5:08 am
shittybutt
User avatar



Location: Berlin
Um...if you read the doc carefully, it says button_down is called every time before update, which itself called on every tick; so button_down will always be called on every tick if a button is pressed, regardless of whether its the same or not.

button_down? is never called by the engine; it is explicitly called by the user. Check the doc, the examples, etc; it doesn't make sense otherwise.


Top Top
Profile      
 

    Dahrkael
  Thu Sep 10, 2009 11:40 am
VOC@LOID #01
User avatar
Member


Location: SPain :D
i checked all and I know how it works, i had some problems with these at the beginning, asked in #gosu (freenode) and in the forums, and now works perfect for me, im sure of what im saying.

button_down can be called in all the frames, but only return one true for key, only one time :3

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


Who is online

Users browsing this forum: No users and 1 guest


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