# Text separation help

**URL:** <https://discourse.processing.org/t/text-separation-help/23859>\
**Category:** Coding Questions\
**Created:** [September 14, 2020, 7:07pm UTC](https://discourse.processing.org/t/text-separation-help/23859 "2020-09-14T19:07:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DariusKempton](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Post date:** [September 14, 2020, 7:07pm UTC](https://discourse.processing.org/t/text-separation-help/23859/1 "2020-09-14T19:07:00Z")

</div>

I am trying to create a Text Adventure game, but i am having problems trying to have both the title for the game and the game text display at the same time. Is there a way to create different text, so that i can have Story be a variable that displays near the center of the screen, while still having custom background colors, and a seperate Title variable that displays at the top of the screen?

```
//Setup
{
	//Main Canvas Setup
	{
	function setup()
	{
		createCanvas(600,600);
		background(0);
		input = createInput();
		input.position(210,500);
		input.size(200);
		button = createButton('submit');
		button.position(430,501);
	}
}
	//Text Control and Game Coloring
	{
		function draw()
		{
			fill(190);
			rect(-1,-1,600,50);
			fill(150);
			rect(-1,50,600,600);
			textAlign(CENTER);
			drawWords(width * 0.5);
		}
	}
	//Story Text
	{
		function drawWords(x)
		{
			textSize(35);
			fill(0);
			text(Story, x, 300);
		}
	}
	//Game Title Text
	{
		function drawWords(x)
		{
			textSize(45);
			fill(0);
			text(Title, x, 36);
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 14, 2020, 8:47pm UTC](https://discourse.processing.org/t/text-separation-help/23859/2 "2020-09-14T20:47:50Z")

</div>

Yes.

You got 2 functions of the same name, change 1 name and call both from draw()

Get rid of the additional { } brackets

---

<div class="post-metadata">

**Author:** ![DariusKempton](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Post date:** [September 14, 2020, 8:49pm UTC](https://discourse.processing.org/t/text-separation-help/23859/3 "2020-09-14T20:49:54Z")

</div>

so should i just change one of them to  
function drawWords(y) ?  
and yeah, im using the extra {} brackets to help group different sections of the code together so its easier for me to find things while editing the code.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 14, 2020, 8:51pm UTC](https://discourse.processing.org/t/text-separation-help/23859/4 "2020-09-14T20:51:26Z")

</div>

Yes

like this maybe?

```auto

//Setup
function setup() {
  createCanvas(600, 600);
  background(0);
  input = createInput();
  input.position(210, 500);
  input.size(200);
  button = createButton('submit');
  button.position(430, 501);
} // setup

// Main function
function draw() {
  fill(190);
  rect(-1, -1, 600, 50);
  fill(150);
  rect(-1, 50, 600, 600);
  textAlign(CENTER);
  drawStory(width * 0.5);
  // what comes here ?
}

//Story Text
function drawStory(x) {
  textSize(35);
  fill(0);
  text(Story, x, 300);
}

//Game Title Text
function drawTitle(x) {
  textSize(45);
  fill(0);
  text(Title, x, 36);
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 14, 2020, 8:59pm UTC](https://discourse.processing.org/t/text-separation-help/23859/5 "2020-09-14T20:59:47Z")

</div>

> [@DariusKempton](#):
>
> im using the extra {} brackets to help group different sections of the code together

Well… yeah…

imho:  
in this case exactly this stopped processing from showing a proper error message (duplicate function name not allowed) and stopped you from being able to work further on it

But problem solved! 😉

---

<div class="post-metadata">

**Author:** ![DariusKempton](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Post date:** [September 14, 2020, 9:00pm UTC](https://discourse.processing.org/t/text-separation-help/23859/6 "2020-09-14T21:00:12Z")

</div>

well, thanks for the help

---

<div class="post-metadata">

**Author:** ![DariusKempton](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Post date:** [September 14, 2020, 9:00pm UTC](https://discourse.processing.org/t/text-separation-help/23859/7 "2020-09-14T21:00:56Z")

</div>

you wouldnt believe how hard it was for me to find this forum btw… for some reason its seperate from the community section of the processing website

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 14, 2020, 9:02pm UTC](https://discourse.processing.org/t/text-separation-help/23859/8 "2020-09-14T21:02:50Z")

</div>

> [@DariusKempton](#):
>
> hard it was for me to find this forum btw… for some reason its seperate from the community section of the processing

I see! Weird!

I am very sorry to hear that!

I am glad you found it.

Warm regards,

Chrisir

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 19, 2020, 7:45pm UTC](https://discourse.processing.org/t/text-separation-help/23859/9 "2020-09-19T19:45:15Z")

</div>

> [@DariusKempton](#):
>
> you wouldnt believe how hard it was for me to find this forum btw… for some reason its seperate from the community section of the processing website

Sorry to hear that. If you are trying to find it again, some techniques that may help:

- search for: `processing.org forum`  
[processing.org forum - Google Search](https://www.google.com/search?q=processing.org+forum)
- or go to any processing site, such as [p5js.org](http://p5js.org) or [processing.org](http://processing.org), and click on “forum” on the left side. It will take you right here.
