Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Community] The community evolutionary XP scripting project

Zeriab

Sponsor

The community evolutionary script project for RMXP

This is a little fun idea I came up with while drunk.
The basic idea is to apply the 5 word story to a script. I.e. each member built a little on the script.
Since writing a script and writing an easy is not the same there are some differences.
I don't expect anything useful to come out, I just expect some fun :D

Rules
Any posts which does not build on a script are completely ignored. I.e. they don't count in the 3-posts rule.

Rule 1: Choose a script from the last 3 submissions (up to)
You have to a script from the last 3 submissions to build on.
Remember that disqualified submissions does not count.
There are two cases where the choice is limited: (Note that the cases may not be mutually exclusive)
  1. There are less than 3 submissions in the topic. This limits the choice to the amount of submissions.
  2. One of your submissions is among the last 3 submissions. This limits the choice to the submissions made after your own. (Yes, this effectively prevents double submissions)


Rule 2: Code restrictions
Rule 2.1 Only one section
Do not write code which uses more than one sections.

Rule 2.2 Stay in RGSS
No Win32API calls, no file creations, no shell executions, etc.

Rule 2.3 Sprites as only form of visual output
Any visual output must be made using a sprite.

Rule 2.4 Comments
Comments are allowed and are ignored in terms of effect on the script.
There are basically no comment restrictions.


Rule 3: Disqualification
A submissions can be disqualified.
Disqualified submissions are ignored in Rule 1.
I will occasionally check up on this topic and disqualify posts if necessary.

Rule 3.1 Handling 'bad' submissions
By bad submissions I mean submissions which will be disqualified in due time.
There will be a period of time from a bad script is submitted until it is disqualified.
In this time period it is still counted among the 3 submissions in Rule 1
Do not pick the submissions if you can see that it will be disqualified.
You are responsible for checking up on the script you pick being ok.
Follow-up disqualification is a definite possibility. (Avalanche disqualification)

Rule 3.2 Immediate disqualifications
Submissions which break Rule 1 are automatically disqualified even before I edit the post.
This means that you should ignore them immediately.

Rule 3.3 Rule violations
Any Rule 2 violation causes immediate disqualification.
Also of follow up scripts. (Think avalanche effect)
Blatant disregard of Rule 4 & 5 will also cause avalanche disqualification.

Rule 3.4 Errors
Syntax errors cause an avalanche disqualification.
For other errors it's a bit more tricky, since it's not feasible to guarantee
You must be able to start the script and exit without problems.
This rule may be amended if necessary. I will give a notification in that case.


Rule 4: Additions
You may add up to 5 new effective code lines to the script.

Rule 5: Modifications
You may alter up to 3 effective code lines.
This includes removal of script lines.
Note that if you remove one statement and add another in its place it only counts as a modification.
If you add two statements in its place it counts as one modification and one addition.

Let's say that we want to swap x and y then one way to do it is:
[ruby]temp = x
x = y
y = temp
[/ruby]

This counts as 3 effective code lines.
You can put it all one line by using ;
[ruby]temp = x; x = y; y = temp
[/ruby]
This still counts as 3 effective the code lines. If you use parallel assignment you get this:
[ruby]x, y = y, x
[/ruby]
That is 1 effective code line.

So there is no reason not to structure it nicely with spacing and line-braking and etc.
Using special language features is encouraged.
In doubt you can look at the grammar for the ruby language with 1 effective code line = 1 statement (stmt)


To run delete everything section except Main.
Replace that with this:

[ruby]# Create scene
$scene = Scene_OurScene.new
# Call main method
while !$scene.nil?
  $scene.main
end
# Fade out
Graphics.transition(20)
[/ruby]

Insert a new section. You can copy the script from a post in there and you should be able to run it.

Rule 6: Submission
Add this in the top of your post if it is a submission:
[size=150]Submission[/size]


If the post does not contain this line it is not considered as a submission.
This (first) post is considered a submission as a special case since it defines the initialize scene.

Be sure to post the entire script and not just the section you have edited.
To ensure the sanity of your fellow scripts please wrap the code in [ruby ][/ruby] or [code ][/code] tags (With the space removed naturally)

It is also a good idea to tell which submission you have picked.


Initial Scene
[ruby]class Scene_OurScene
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
 
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
 
  def update
    if Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    elsif Input.press?(Input::LEFT)
      @sprite.x -= 9
    elsif Input.press?(Input::DOWN)
      @sprite.y += 9
    elsif Input.press?(Input::UP)
      @sprite.y -= 9
    elsif Input.press?(Input::RIGHT)
      @sprite.x += 9
    end    
  end
end
[/ruby]

*hugs*
 

Zeriab

Sponsor

You can do that if you want.
You can also do $scene.main until $scene.nil? if you prefer.
It doesn't really matter.

What matters is that the script is compatible with the test script I specified.
 
Submission

[rgss]# Based on: Initial Scene (Zeriab)
# Changes: 4 lines (+ 1 comment line) added to OurScene.update for sprite transparency changing on button press functionality
 
# maybe we want to keep this comment formatting stuff up for tracking purposes?
# also, as a kind gift from The Third Man: definition seperators
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    if  Input.press?(Input::A)
      # makes sprite halfway transparent within [ 64 / Graphics.frame_rate ] seconds
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    elsif Input.press?(Input::LEFT)
      @sprite.x -= 9
    elsif Input.press?(Input::DOWN)
      @sprite.y += 9
    elsif Input.press?(Input::UP)
      @sprite.y -= 9
    elsif Input.press?(Input::RIGHT)
      @sprite.x += 9
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
  end
  #--------------------------------------------------------------------------
end
[/rgss]


For reassurance purposes: I'm only allowed to post if my last post isn't among the last three effective posts, right?
Also, can I / we change existing lines? Moving a gray rectangle around won't be too fun after a while... ^^ (and changing it directly after your script would be pretty damn dumb as well...) There'd also be a need for the C/B keys sooner or later.

Other than that: Awesome idea, I'm surprised this hasn't been done yet... I think I'll enjoy it pretty much :) Let's hope it lives!
 

Zeriab

Sponsor

I thought that you would just post the script, but I can see my lack of specification may lead to confusion.
I have updated the rules with the concept of a submission and been explicit on what it should contain.
The fact that you should post the entire script containing your changes is now more clear.
Can I get you to post your changes again so it fits with the new rules?

As stated in Rule 1.2 you are allowed to make a submission even if your last submission is among the last three, but you can only choose among submissions made after your last submission. (If your last submission is the last submission, then you cannot post a submission)

Rule 5 states that you can alter up to 3 effective code lines. I have added some elaboration since it was not clear how Rule 4 & Rule 5 works together. The answer is yes. You can change existing lines.

I am glad you like the idea and I also hope it lives ^_^
Please do tell if there are anything else you want clarified.

*hugs*
 
Changed it accordingly.


First of all, sorry for not reading the rules right... I sometimes have problems with that ;)

Also, regarding the submissions... since you can always choose freely from the last three submissions, including your own, it's theoretically possible for one person to script their very own script by always skipping what others are adding ;)

Also, is it "5 additional lines plus 3 changed lines", or "5 additional lines or 3 changed lines"? And of course, if there's a definition defined, and I change it's handle (for example def produce to def produce(material)), do I have to change all the referers or are they automatically changed along with it? (aka does it count towards the line count).

Just asking questions that might be important in five years from now ^^"


Also: Aren't you participating?

EDIT: Also... why wouldn't it be if Input.trigger?(Input::B) || Input.trigger?(Input::C) ? Oo
 

Zeriab

Sponsor

BlueScope":3ou4rk1n said:
Also, regarding the submissions... since you can always choose freely from the last three submissions, including your own, it's theoretically possible for one person to script their very own script by always skipping what others are adding ;)
Read Rule 1.2 again. I don't see you managed to conclude that :huh:

BlueScope":3ou4rk1n said:
First of all, sorry for not reading the rules right... I sometimes have problems with that ;)
:haha:

Sorry, couldn't resist ._.

BlueScope":3ou4rk1n said:
Also, is it "5 additional lines plus 3 changed lines", or "5 additional lines or 3 changed lines"? And of course, if there's a definition defined, and I change it's handle (for example def produce to def produce(material)), do I have to change all the referers or are they automatically changed along with it? (aka does it count towards the line count).
It's up to 5 additions plus up to 3 changes.
Changing the handle is one change. You don't have to change all the referers. It's a choice you have to make. There is no freebies for changing the referers. I.e. if you change a referer it counts as a change.

BlueScope":3ou4rk1n said:
Also: Aren't you participating?
I will participate ^^

BlueScope":3ou4rk1n said:
EDIT: Also... why wouldn't it be if Input.trigger?(Input::B) || Input.trigger?(Input::C) ? Oo
Using .press? instead of .trigger? doesn't break any rules. There is nothing wrong with the way it is now and there would be nothing wrong with you changing it.
You can perfectly fine change it if you want ^_^
Similarly people can keep your commenting style or ignore it.

*hugs*
 

MicKo

Member

Submission - Disqualified
[ruby]# Based on: Script by BlueScope
# Changes: 3 "end" added to OurScene.update for 8 direction movement
#          4 "elsif" changed into "if", moved sprite's opacity part accordingly
 
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    if  Input.press?(Input::A)
      # makes sprite halfway transparent within [ 64 / Graphics.frame_rate ] seconds
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    if Input.press?(Input::LEFT)
      @sprite.x -= 9
    end
    if Input.press?(Input::DOWN)
      @sprite.y += 9
    end
    if Input.press?(Input::UP)
      @sprite.y -= 9
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += 9
    end
  end
  #--------------------------------------------------------------------------
end
[/ruby]
Is it okay ? D:
 
@Zeriab: I see what you're saying now ^^" Sorry! ^^"

@Micko: I don't really see the '3' and '4' in your comment header, but I know the first line would be this, if following my style:
Code:
# Based on: Script by BlueScope
Something like that, simply as an identifier of what script you used as a base... which is really why I'd make it a rule of some sort or something, because otherwise, checking for not rule conform things would be hard after a while...

Also, the sprite now changes opacity back to regular even if moving :(
^^


EDIT:

Submission

[ruby]# Based on: Script by MicKo
# Changes: 4 lines added to OurScene.update to prevent sprite from moving offscreen
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    if  Input.press?(Input::A)
      # makes sprite halfway transparent within [ 64 / Graphics.frame_rate ] seconds
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    if Input.press?(Input::LEFT)
      @sprite.x -= 9
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += 9
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= 9
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += 9
      @sprite.x = 608 if @sprite.x > 608
    end
  end
  #--------------------------------------------------------------------------
end
[/ruby]

I really want to move that sprite around now! Too bad I don't have any maker at work :| (someone make a non-RTP demo! :haha: )
 

Zeriab

Sponsor

I am sorry Micko. The rule clearly states up to 3 modifications while you are perfectly aware that you have made more. You use 4 modifications for elsif => if and one modification for moving the else branch up.

I'll have to disqualify your post.
Since it was only a minor failure I won't disqualify Bluescope's extension ^_^

*hugs*
 

Zeriab

Sponsor

Submission
[ruby]# Based on: Script by BlueScope
# Changes: 5 lines added, 2 constants and 3 in update for speed init & boost
#          2 lines changed in update for horizontal speed
 
class Scene_OurScene
  NORMAL_SPEED = 9 # [ADD]
  BOOST_SPEED = 27 # [ADD]
  #--------------------------------------------------------------------------
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED # [ADD]
    if Input.press?(Input::A)
      # makes sprite halfway transparent within [ 64 / Graphics.frame_rate ] seconds
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    elsif Input.press?(Input::X) # [ADD]
      speed = BOOST_SPEED # [ADD]
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    if Input.press?(Input::LEFT)
      @sprite.x -= speed # [MOD]
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += 9
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= 9
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed # [MOD]
      @sprite.x = 608 if @sprite.x > 608
    end
  end
  #--------------------------------------------------------------------------
end
[/ruby]

In case you are wondering, I am going to split my administrative posts from my submissions.
 
Submission

[ruby]# Based on: Script by Zeriab
# Changes: 4 lines (+1 comment line) added in OurScene.update to allow boosting only if not any transparent
#          2 lines changed in OurScene.update for vertical speed
#          plus free bonus seperator for script style purposes, honourably sponsored by The Third Man's workplace
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  NORMAL_SPEED = 9
  BOOST_SPEED = 27
  #--------------------------------------------------------------------------
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED
    if Input.press?(Input::A)
      # makes sprite halfway transparent within [ 64 / Graphics.frame_rate ] seconds
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    elsif Input.press?(Input::X)
      # allows boosting if not transparent
      if @sprite.opacity == 255 # ADD
        speed = BOOST_SPEED
      else # ADD
        speed = NORMAL_SPEED # ADD
      end # ADD
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed # MOD
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed # MOD
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
  end
  #--------------------------------------------------------------------------
end
[/ruby]

I also indented the line inbetween my additional lines a bit for scripting style purposes... which I doubt counts as modification, but in any case, I have one left ;)

I really like this thread!
 

Zeriab

Sponsor

There is nothing with changing white space as long as it doesn't make any semantic changes ^_^
I am glad this thread seems to take of fairly well ^_^

It's also nice to see that you followed up on my speed idea :D
 

MicKo

Member

Sorry about the few additionnal lines the last time Zeriab. ;_;

Submission
[ruby]# Based on: Script by BlueScope
# Changes: 5 lines added in OurScene.initialize to draw a new Sprite.
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  NORMAL_SPEED = 9
  BOOST_SPEED = 27
  #--------------------------------------------------------------------------
  def initialize
    @hole_sprite = Sprite.new # ADD
    @hole_sprite.x = 484 # ADD
    @hole_sprite.y = 89  # ADD
    @hole_sprite.bitmap = Bitmap.new(32,32) # ADD
    @hole_sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(50,50,50)) # ADD
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED
    if Input.press?(Input::A)
      # makes sprite halfway transparent within [ 64 / Graphics.frame_rate ] seconds
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    elsif Input.press?(Input::X)
      # allows boosting if not transparent
      if @sprite.opacity == 255
        speed = BOOST_SPEED
      else
        speed = NORMAL_SPEED
      end
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
  end
  #--------------------------------------------------------------------------
end
[/ruby]
Damn, I can't dispose my sprite yet. >:eek:
 
Of course I followed that idea... that's the purpose of the 5/3 line limit now, isn't it - making other people see what the last person might not be able to complete within their bounds, and complete it for them. ^^ (hence "Community", no? ;) )

And yeah, until now, there's not much happening but the two of us... aka me, as you're hardly doing anything either :> But I think it will RISE :D

EDIT: Of course, it's less fun with people saying what they didn't include yet :(

And yeah... for what reason exactly is @hole_sprite above @sprite? >_< (I can actually tell why you'd do that, but personally, I could live with the next person changing the z value...)


Submission

[ruby]# Based on: Script by MicKo
# Changes: 2 lines added in OurScene to create sprite appearance changing method
#          1 line added in OurScene.update to call sprite appearance changing method
#          1 line added to OurScene.main to dispose @hole_sprite
#          2 lines shifted around, 1 end tag placed, and 1 line modified in total to eliminate possible transparency bugs in combination with other keys used
#          comments updated for OurScene.update to better reflect what each section does, now that it's better seperated
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  NORMAL_SPEED = 9
  BOOST_SPEED = 27
  #--------------------------------------------------------------------------
  def initialize
    @hole_sprite = Sprite.new
    @hole_sprite.x = 484
    @hole_sprite.y = 89
    @hole_sprite.bitmap = Bitmap.new(32, 32)
    @hole_sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(50,50,50))
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
    @hole_sprite.dispose # ADD
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED
    # transparency handler
    if Input.press?(Input::A)
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    else # MOD
      @sprite.opacity += 2 unless @sprite.opacity == 255 # MOD
    end #ADD
    # boost handler
    if Input.press?(Input::X) # MOD
      if @sprite.opacity == 255
        speed = BOOST_SPEED
      else
        speed = NORMAL_SPEED
      end
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    end
    # movement handlers
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
    # sprite's visuals handler
    update_sprite_appearance # ADD
  end
  #--------------------------------------------------------------------------
  def update_sprite_appearance # ADD
  end # ADD
  #--------------------------------------------------------------------------
end
[/ruby]
 
Let's see if I did it right this time...

Submission - Disqualified
[rgss]# Based on: Script by MicKo and BlueScope's update
# Changes: Turned NORMAL_SPEED and BOOST_SPEED into a single array named SPEED
#          Changed all referrals to NORMAL_SPEED and BOOST_SPEED with SPEED[0] or SPEED[1]
#          After line "if Input.press?(Input::X)" I included a ternary condition to replace the
#          if else one and deleted some lines because of that
#          In line 51 replaced $scene = nil with exit to achieve the same purpose
#          In line 57 changed the speed behavior so it only increments its y coord position value
#          if its last value was lower than 448. Otherwise it does not change it.
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  SPEED = [9, 27] # MOD
  #--------------------------------------------------------------------------
  def initialize
    @hole_sprite = Sprite.new
    @hole_sprite.x = 484
    @hole_sprite.y = 89
    @hole_sprite.bitmap = Bitmap.new(32, 32)
    @hole_sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(50,50,50))
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
    @hole_sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = SPEED[0] # MOD
    # transparency handler
    if Input.press?(Input::A)
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    # boost handler
    if Input.press?(Input::X)
      speed = @sprite.opacity == 255 ? SPEED[1] : SPEED[0] # MOD
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      exit # MOD
    end
    # movement handlers
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed if @sprite.y < 448 # MOD
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
    # sprite's visuals handler
    update_sprite_appearance
  end
  #--------------------------------------------------------------------------
  def update_sprite_appearance
  end
  #--------------------------------------------------------------------------
end
[/rgss]

Is it OK now?
 

MicKo

Member

BlueScope":26dl6lir said:
And yeah... for what reason exactly is @hole_sprite above @sprite? >_< (I can actually tell why you'd do that, but personally, I could live with the next person changing the z value...)
I don't see the problem here, but fine I'll fix that. :p

kyonides, you modified 5 lines instead of 3 and you didn't include "Submission" in your post so I'm going to assume we can't use your submission, sorry. ;_;

Submission
[ruby]# Based on: Script by BlueScope
# Changes: 2 added lines in Scene_OurScene.initialize
#          3 added lines in Scene_OurScene.update_sprite_appearance
#          3 modified lines in Scene_OurScene.initialize
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  NORMAL_SPEED = 9
  BOOST_SPEED = 27
  #--------------------------------------------------------------------------
  def initialize
    @hole_sprite = Sprite.new
    @hole_sprite.x = 484
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
    @hole_sprite.y = 89 # MOD
    @hole_sprite.bitmap = Bitmap.new(32, 32) # MOD
    @hole_sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(50,50,50)) # MOD
    @hole_sprite.z = @sprite.z - 1 # ADD
    @speed = NORMAL_SPEED # ADD
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
    @hole_sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED
    # transparency handler
    if Input.press?(Input::A)
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    # boost handler
    if Input.press?(Input::X)
      if @sprite.opacity == 255
        speed = BOOST_SPEED
      else
        speed = NORMAL_SPEED
      end
    elsif Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    end
    # movement handlers
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
    # sprite's visuals handler
    update_sprite_appearance
  end
  #--------------------------------------------------------------------------
  def update_sprite_appearance
    if @speed == NORMAL_SPEED # ADD
      @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196)) # ADD
    end # ADD
  end
  #--------------------------------------------------------------------------
end
[/ruby]
 
MicKo":3t214f46 said:
BlueScope":3t214f46 said:
And yeah... for what reason exactly is @hole_sprite above @sprite? >_< (I can actually tell why you'd do that, but personally, I could live with the next person changing the z value...)
I don't see the problem here, but fine I'll fix that. :p
The problem with that is that the two sprites will have the same auto-generated z-level (I think 200?), so they'll virtually be on the same level and therefore be... threaded (dunno any onther way to say that), meaning as long as ones y-value is lower than the others, it'll appear 'lower' on the z axis, and vice versa. Doing it according to your correction, the hole sprite will always stay below the avatar sprite, which is definately what we want ;)

@kyo: You really did violate the rules there quite a bit... what I'll do is somewhat take your idea and include it in a legal way, so we're fine.

Also, I'm not sure you knew what you were doing when modifying the @sprite.y line... that sets your sprite to the bottom of the screen each time you press down, which is... strange and I think unwanted?^^

Other than that, welcome aboard!

Submission

[ruby]# Based on: Script by MicKo
# Changes: 4 lines added, 3 modified
# (I'm easing the protocolling here up quite a bit, since Zeriab came up with the much easier line tagging)
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  NORMAL_SPEED = 9
  BOOST_SPEED = 27
  #--------------------------------------------------------------------------
  def initialize
    @hole_sprite = Sprite.new
    @hole_sprite.x = 484
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
    @hole_sprite.y = 89
    @hole_sprite.bitmap = Bitmap.new(32, 32)
    @hole_sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(50,50,50))
    @hole_sprite.z = @sprite.z - 1
    @speed = [9, 27] # MOD
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
    @hole_sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED
    @current_speed = @speed[0] # ADD
    # transparency handler
    if Input.press?(Input::A)
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    # boost handler
    if Input.press?(Input::X)
      if @sprite.opacity == 255
        speed = BOOST_SPEED
      else
        speed = NORMAL_SPEED
      end
    end # ADD
    # exit handlers
    if Input.press?(Input::C) || Input.press?(Input::B) # MOD
      $scene = nil
    end
    # movement handlers
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
    # sprite's visuals handler
    update_sprite_appearance
  end
  #--------------------------------------------------------------------------
  def update_sprite_appearance
    if @current_speed == @speed[0] # MOD
      @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196, 196, 196))
    elsif @current_speed == @speed[1] # ADD
      @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(255, 128, 0)) # ADD
    end
  end
  #--------------------------------------------------------------------------
end
[/ruby]
 

MicKo

Member

Oh, thanks for the clarification BlueScope, I didn't know about that, good to know! :D

Ok, here's my Submission, sorry it's messing with a boost, I hope you don't mind.
[ruby]# Based on: Script by BlueScope
# Changes: 5 lines added, 3 modified
 
class Scene_OurScene
  #--------------------------------------------------------------------------
  NORMAL_SPEED = 9
  BOOST_SPEED = 27
  #--------------------------------------------------------------------------
  def initialize
    @sprite = Sprite.new
    @sprite.x = 304
    @sprite.y = 224
    @sprite.bitmap = Bitmap.new(32, 32)
    @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196,196,196))
    @hole_sprite = Sprite.new # MOD
    @hole_sprite.x = 484 # MOD
    @hole_sprite.y = 89
    @hole_sprite.bitmap = Bitmap.new(32, 32)
    @hole_sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(50,50,50))
    @hole_sprite.z = @sprite.z - 1
    @speed = [9, 27]
  end
  #--------------------------------------------------------------------------
  def main
    Graphics.transition
    until $scene != self
      Input.update
      Graphics.update
      update
    end
    Graphics.freeze
    @sprite.dispose
    @hole_sprite.dispose
  end
  #--------------------------------------------------------------------------
  def update
    speed = NORMAL_SPEED
    @current_speed = @speed[0]
    # transparency handler
    if Input.press?(Input::A)
      @sprite.opacity -= 2 unless @sprite.opacity <= 128
    else
      @sprite.opacity += 2 unless @sprite.opacity == 255
    end
    # boost handler
    if Input.press?(Input::X)
      if @sprite.opacity == 255
        @current_speed += 1 unless @current_speed == @speed[1] # MOD
      else
        speed = NORMAL_SPEED
      end
    else # ADD
    end
    # exit handlers
    if Input.press?(Input::C) || Input.press?(Input::B)
      $scene = nil
    end
    # movement handlers
    if Input.press?(Input::LEFT)
      @sprite.x -= speed
      @sprite.x = 0 if @sprite.x < 0
    end
    if Input.press?(Input::DOWN)
      @sprite.y += speed
      @sprite.y = 448 if @sprite.y > 448
    end
    if Input.press?(Input::UP)
      @sprite.y -= speed
      @sprite.y = 0 if @sprite.y < 0
    end
    if Input.press?(Input::RIGHT)
      @sprite.x += speed
      @sprite.x = 608 if @sprite.x > 608
    end
    # sprite's visuals handler
    update_sprite_appearance
  end
  #--------------------------------------------------------------------------
  def update_sprite_appearance
    if @current_speed == @speed[0]
      @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(196, 196, 196))
    elsif @current_speed == @speed[1]
      @sprite.bitmap.fill_rect(0, 0, 32, 32, Color.new(255, 128, 0))
    end
    # change sprite's opacity and disallow boost for a moment if touching the hole
    if (@sprite.x + 32).between?(@hole_sprite.x + 8, @hole_sprite.x + 56) && # ADD
    (@sprite.y + 32).between?(@hole_sprite.y + 8, @hole_sprite.y + 56) # ADD
      @sprite.opacity = 100 # ADD
    end # ADD
  end
  #--------------------------------------------------------------------------
end
[/ruby]
 
It's good that people can still learn something from this! (which I know it's dear absent creator Zeriab will like ;) )

Actually, I "learned" something from you before, being this:
Code:
@hole_sprite.z = @sprite.z - 1
I seriously never thought about just taking another sprite's z-level and setting the current one 1 below :x


Anyway, regarding your script: First of all, you only added four lines, no matter how many '# ADD's you placed in your script ^^ That is due to the fact that
Code:
# if (@sprite.x + 32).between?(@hole_sprite.x + 8, @hole_sprite.x  + 56) && (@sprite.y + 32).between?(@hole_sprite.y + 8, @hole_sprite.y + 56)
is one line, just like Zeriab's example of
Code:
temp = x; x = y; y = temp
is three lines - we don't count real line numbers for the rules, but effective lines read by the interpreter (which isn't totally true, as the interpreter reads it as two lines, but it does connect them, so yeah - it counts as one line).

Second, you direct this script in a harsh direction and I just want to make you aware of a certain fact, in case you are not, being the utilization of opacity. I made it a way of controlling the character, as in making you able to purposefully make yourself halfway transparent for not closer defined reasons. You set it as a likely punishing result of stepping into a hole, which is kind of irritating, since unless the player has masochistic tendencies, he probably wouldn't want to trigger enemy effects himself.
That being said, please by all means keep it the way it is if it's intentional, because I can imagine a few ways of how to utilize this ;)

You also advance the value range quite a bit, which has been 255 (100%) and 128 (50%). Now there's also 100 (39something %), which might cause problems later in the handling of opacity changing, and in fact already enables you to stay at a lower value than 128 forever, which is when you press the A button whenever you hit a hole.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top