Can anyone help me shorten my code? or less heavy? (plus how to make a restart button)

hey! I’m still really new to processing TT
but I’m getting there!!

right now I want to make a short interactive story using processing(IDK if that’s a good idea or not but I’m trying!)

so I got it down pretty well!! but it’s just A LOT OF CODE
like ti takes 35 seconds to load every time I run it

and I basically just muscled through and made the code super long but I’m pretty sure there must be a way to shorten it!

p.s I would also appreciate it if someone could help me make a restart button… TT
I am new with it comes to SCENE transfers so I’m not really sure how to make a restart button besides making a specific button for each ending that’ll take it back to the beginning but I’m wondering if there’s just a way to make a button class that will automatically go to the beginning and I can just simply put it at the end of any scene I want.

MY CODE:

1 Like

I dunno why it won’t let me post a PASTEBIN link so I have a google docs instead.

1 Like

I suspect that this is just because it is loading a lot of resources especially the sound and movies files so not much you can do there.

If you simply want a visible button that you can click then there are GUI libraries available e.g. G4P and controlP5 both of which are very popular.

1 Like
  1. WET vs DRY: I see blocks of similar code like “text box outline” dozens of times. Try making those functions. That will eg turn 6 lines into 1 many places.

  2. Load just in time. Is this a visual novel with a limited number of next scenes? If so, consider only loading things like images in the scene just before you need them (or when a scene starts). Then you don’t have to preload everything all at once.

2 Likes