High performance high quality text rendering I’ve just finished working on.

This is part of a larger project but the text rendering is done.

Scaling up text that's of normal sizes like size 32 looks awful, you could just use a bigger font size but if your text is scaled at all then that won't work.

This was a problem for me because my project requires being able to zoom in and out.

There is the SHAPE mode, but the performance is quite bad.

So what I've made in my application, is something that automatically scales font detail based on the current scaling at draw-time. If you zoom in or the text is scaled up for any reason, it will load in a larger font, and then scale back down when drawing so that the apparent size is no different, just the quality.

The minimum size is 1 and the maximum size is 512 (I had issues going up to 1024).

I made a new font class for this. When you create the font you set the size, which will be its apparent size, and you can also set the scaling period, and whether to over-render.

The scaling period is, if you set it to 2, the font quality will increase for every doubling in scale. The over-render option just makes it so that the font is always higher than what it should be for the screen, so even though it scales you always see it at at least native quality. You can have a scaling period of something like 1.1 if you want and that still works fine.

It works by pre-loading the font sizes for the scaling period when you create the font, and then when you draw text with that font it calculates which font size to use.

Pre-loading means less jittering as lots of fonts get created.

Here's some videos where I compare performance and quality of my method and other more common options. There's an FPS counter. I do have some optimisations for when text is off screen but that applies to all the options I show not just my own, but that is why you'll see frame rates go up as I zoom in. The videos are in 4K but they might not have finished processing up to 4K resolution yet.

The max framerate I set is 240, there is a lot of text on screen to stress test.

First, the problem:

https://www.youtube.com/watch?v=bI58VguqV0w

Here is with text size 32, using the MODEL textMode. Obviously the issue is as you zoom in the quality is quite bad.

My solution:

https://www.youtube.com/watch?v=DXGlKNsKR7s

Scaling period is 2 and over-render is on (it's defaulted to true). Performance is equivalent to just using text at size 32, 40~ FPS at full view and max FPS when zoomed in, but the quality is much better.

What about SHAPE mode?:

https://www.youtube.com/watch?v=VoffRmPVKo0

This video is not longer intentionally. In full view the frame rate is 0.5~, going up to around 100 when zoomed in to just one character. It does have the advantage of having infinite quality though.

What about just loading in 512 sized fonts?:

https://www.youtube.com/watch?v=TEL3ruvaZCQ

This gets you equivalent quality to my method, and is still much better performance than SHAPE, but it gets about 4 times less FPS compared to my method in the full view (though it reaches max FPS when zoomed in). So there's still performance benefits to scaling font quality.

What does text quality scaling look like?:

Here's a video with over-render turned off, and the scaling period is 4, normally you wouldn't notice the quality scaling, it would just be like everything was 512 fonts, but with these settings you can see it in action even though it doesn't look as good.

https://www.youtube.com/watch?v=K2MnVYTMq2U

submitted by /u/Saytahri
[link] [comments]

Нow I wаs fоund only sеx in the Internet websitе.Mу real eхреrience with 3 girls fоr guуs

Hey guys.

Recently, I realized the best way to find a girl – it’s dating in the Internet.
I registered on the most popular dating sites, but with these girls had a long time to correspond, they are reluctant to answer and only sometimes agreed on the life dating.

Personally, I would like to find a girl for sex, without relations.

One day my friend advised to look for online dating sites for sex. At which the girls are registered with the same goal - to find a partner for sex.

It turned out that there’re many these sites. I registered on the most popular websites.

But most of them had one minus. This is usually paid sites, they require a monthly subscription and on these [sites registered more men than women.

"Which dating site is free and proven" - I asked this question in the men forums

I’ve registered at all of them, but in the end I found one good dating website. I note that it's free and always a lot of girls from different cities are online.

If someone is interested, here it’s the site: http://hookupteg.com

What about me: I had sex 3 times in the past month with different girls from this website.

submitted by /u/Thomasviatran
[link] [comments]

[Question] Having enemies spawn at time intervals?

This is a pretty stupid question and i feel like I should know how to do this but I can't think of anyway I could do this. This is also a school project as per the rules say just give me a good enough hint to get my brain rolling in the right direction.

So what I want to do is have enemies spawn at time intervals. I tried to make it spawn the spawn thing in my code updated every half a second. But since i wasn't thinking straight all that ended up doing was only spawning the same enemy ever half a second.

I was wondering what's a way I could fix this here's a snip bit of my code so you can see how I spawn enemies in I guess. It's probably no the most effective way I could do this so sorry.

void spawnEnemies() { if (level > 0 && level < 3) { for (int a = 0; a < smallEnemy; a ++) { smallEnemies[a].displayEnemy(); } } else if (level >= 3 && level < 7) { for (int a = 0; a < smallEnemy; a ++) { smallEnemies[a].displayEnemy(); } for (int b = 0; b < mediumEnemy; b ++) { mediumEnemies[b].displayEnemy(); } } else { for (int a = 0; a < smallEnemy; a ++) { smallEnemies[a].displayEnemy(); } for (int b = 0; b < mediumEnemy; b ++) { mediumEnemies[b].displayEnemy(); } for (int c = 0; c < bigEnemy; c ++) { } } } 

I should probably add this so you can see what I was doing before when I tried to add a time interval myself.

int spawnRate = 500 int lastTimeChecked; int smallEnemy; level() { lastTimeChecked = millis(); smallEnemy = 4; } void spawnEnemies() { int a = 0; if (level > 0 && level < 3) { if (millis() - lastTimeChecked > spawnRate && smallEnemy != a) { smallEnemies[a].displayEnemy(); lastTimeChecked = millis(); a ++; } } } 

I'm going off of memory but I think this is how i coded it.

This display function in my separate class does basically everything it dictates the movement of the enemy. I want to figure out how i can make it spawn at intervals because in game the enemies end up clumping together in one spot which makes the user have problems as he has to see what he's typing. here's a screenshot of what I'm talking about. but if I had the game able to spawn a time intervals of my choosing I would be able to avoid this problem almost entirely. Any help would be greatly would be appreciated.

edit: fixed code within second coding part.

submitted by /u/NonExistent23
[link] [comments]

Please. I am going insane. Please help

I'm trying to make an asteroids/galaga game for a school project, but this thing keeps happening where in level 2 the stars in the background only appear when you press space, and I can't figure out why. Can anyone please help me?

Code:

Ship saucer = new Ship(); Ship saucer2 = new Ship(); Rock[] rocks = new Rock[50]; Galaga[] ships = new Galaga[10]; float[] starx = new float[50]; float[] stary = new float[50]; boolean start = false; boolean fail = false; boolean win = false; boolean level2 = false; PFont font1; int explo = 10; float health = 100; void setup() { size(500, 500); for (int i=0; i<50; i++) { // initialising star positions starx[i] = random(0, 500); stary[i] = random(0, 500); } for (int i=0; i<50; i++) { // initialising asteroids rocks[i] = new Rock(); } font1 = loadFont("KozGoPro-ExtraLight-48.vlw"); for (int i=0; i<10; i++) { ships[i] = new Galaga(i*45+40, 40); } }

void draw() { if (start == false) {// start screen background(0);

fill(255); textFont(font1); textAlign(CENTER); textSize(24); text("You are an alien coming to invade \nEarth and kill all humans. \nYou must navigate through\n the asteroid belt and \navoid getting hit! \n\nPress space to start", 250, 100); if (key == ' ') { // pressing space starts game start=true; } 

}

if (start == true) { // if game is started background(0); noCursor();

for (int i=0; i<50; i++) {//creating stars fill(255); ellipse(starx[i], stary[i], 1, 1); } saucer.move(); if (fail==false) {//saucer disappears when you die saucer.display(); } for (int i=0; i<50; i++) { // calling rocks if (fail==false) {//rocks stop moving after you die rocks[i].move(); } rocks[i].display(); if ( dist(saucer.x, saucer.y, rocks[i].x, rocks[i].y) < rocks[i].size+15) {//checking if crashed rocks[i].x = 4000; health = health - 34; } if (health < 0) { fail=true; } } if (saucer.y < 0) {// win condition: saucer to the top edge of screen win = true; } if (win == true) {// win screen saucer.x = -4000; background(0); fill(255); text("You win! Your ship has passed the asteroid belt \n and is continuing on to Earth \n \n Press c to continue to Level Two", 250, 200); if (key == 'c') { level2 = true; start = false; } } if (fail == true) { if (explo<50) {//saucer explodes explo++; } fill(#F7710A); ellipse(saucer.x, saucer.y, explo, explo); fill(255); text("You lose! \nThe human race lives on", 250, 200); } if (win == false) {//health does not appear on win screen if (health>0) {//if ship health is positive fill(#F70A0A); rect(20, 460, health, 20); textAlign(LEFT, BOTTOM); textSize(18); text("Ship Health", 20, 460); textAlign(CENTER); textSize(24); } } 

} // LEVEL TWO !!!!!!!!!!

// LEVEL TWO !!!!!!!!!! if (level2==true) { background(0); for (int i=0; i<50; i++) {//creating stars fill(255); ellipse(starx[i], stary[i], 1, 1); } saucer2.move();
for (int i=0; i<10; i++) { ships[i].display(); ships[i].move(); ships[i].lasers(); if (dist(saucer2.x, saucer2.y, ships[i].laserposx, ships[i].laserposy) <30) { fail = true; } if (fail==false) { saucer2.display(); } }

if (fail == true) { if (explo<50) {//saucer explodes explo++; } fill(#F7710A); ellipse(saucer2.x, saucer2.y, explo, explo); fill(255); text("You lose! \nThe human race lives on", 250, 200); } 

} }

class Ship { int x; int y; Ship () { x = 250; y = 400; }

void move() { //WASD motion if (fail == false) { if (x>20) {//cannot move past left edge of screen if (key == 'a') { x = x-3; } } if (x<480) {//cannot move past right edge of screen if (key == 'd') { x = x +3; } } if (key == 's') { y = y+3; } if (key == 'w') { y = y-3; } } } void display() { noStroke(); fill(#393838); ellipse(x, y, 40, 40); fill(#676666); ellipse(x, y, 30, 30); fill(#CECECE); stroke(1); ellipse(x, y, 10, 10); } }

class Rock { float x; float y; float size; float speed; Rock () { x = random(20, 480); y = random(-500, 200); size = random(10, 30); speed = random(1, 2); } void move() { y = y + speed; }

void display() { noStroke(); fill(#6F4219); ellipse(x, y, size, size); } }

class Galaga { float x; float y; float speed = 1; float shoot; float laserposx; float laserposy; boolean shot = false; Galaga (int tempx, int tempy) { y = tempy; x = tempx; } void display() { fill(#6F6E6E); noStroke(); fill(#6F6E6E); ellipse(x, y, 30, 30); fill(0); rect(x, y+15, 15, 15); triangle(x-15, y, x+15, y, x, y-40); rectMode(CENTER); fill(255); ellipse(x, y, 10, 5); } void move() { y = y + .3; x = x + speed; if (x>480) { speed = -1 ; } if (x<20) { speed = 1 ; } if (y>540) { y = -15; } } void lasers() {

shoot = random(0, 201); if (shoot > 200 ) { shot = true; laserposy = y + 20; laserposx = x; } if (shot == true) { fill(255, 0, 0); rect(laserposx, laserposy, 4, 20); laserposy = laserposy + 2; } 

} }

submitted by /u/gishnu11
[link] [comments]

Please. I am going insane. Please help

I'm trying to make an asteroids/galaga game for a school project, but this thing keeps happening where in level 2 the stars in the background only appear when you press space, and I can't figure out why. Can anyone please help me?

Code:

Ship saucer = new Ship(); Ship saucer2 = new Ship(); Rock[] rocks = new Rock[50]; Galaga[] ships = new Galaga[10]; float[] starx = new float[50]; float[] stary = new float[50]; boolean start = false; boolean fail = false; boolean win = false; boolean level2 = false; PFont font1; int explo = 10; float health = 100; void setup() { size(500, 500); for (int i=0; i<50; i++) { // initialising star positions starx[i] = random(0, 500); stary[i] = random(0, 500); } for (int i=0; i<50; i++) { // initialising asteroids rocks[i] = new Rock(); } font1 = loadFont("KozGoPro-ExtraLight-48.vlw"); for (int i=0; i<10; i++) { ships[i] = new Galaga(i*45+40, 40); } }

void draw() { if (start == false) {// start screen background(0);

fill(255); textFont(font1); textAlign(CENTER); textSize(24); text("You are an alien coming to invade \nEarth and kill all humans. \nYou must navigate through\n the asteroid belt and \navoid getting hit! \n\nPress space to start", 250, 100); if (key == ' ') { // pressing space starts game start=true; } 

}

if (start == true) { // if game is started background(0); noCursor();

for (int i=0; i<50; i++) {//creating stars fill(255); ellipse(starx[i], stary[i], 1, 1); } saucer.move(); if (fail==false) {//saucer disappears when you die saucer.display(); } for (int i=0; i<50; i++) { // calling rocks if (fail==false) {//rocks stop moving after you die rocks[i].move(); } rocks[i].display(); if ( dist(saucer.x, saucer.y, rocks[i].x, rocks[i].y) < rocks[i].size+15) {//checking if crashed rocks[i].x = 4000; health = health - 34; } if (health < 0) { fail=true; } } if (saucer.y < 0) {// win condition: saucer to the top edge of screen win = true; } if (win == true) {// win screen saucer.x = -4000; background(0); fill(255); text("You win! Your ship has passed the asteroid belt \n and is continuing on to Earth \n \n Press c to continue to Level Two", 250, 200); if (key == 'c') { level2 = true; start = false; } } if (fail == true) { if (explo<50) {//saucer explodes explo++; } fill(#F7710A); ellipse(saucer.x, saucer.y, explo, explo); fill(255); text("You lose! \nThe human race lives on", 250, 200); } if (win == false) {//health does not appear on win screen if (health>0) {//if ship health is positive fill(#F70A0A); rect(20, 460, health, 20); textAlign(LEFT, BOTTOM); textSize(18); text("Ship Health", 20, 460); textAlign(CENTER); textSize(24); } } 

} // LEVEL TWO !!!!!!!!!!

// LEVEL TWO !!!!!!!!!! if (level2==true) { background(0); for (int i=0; i<50; i++) {//creating stars fill(255); ellipse(starx[i], stary[i], 1, 1); } saucer2.move();
for (int i=0; i<10; i++) { ships[i].display(); ships[i].move(); ships[i].lasers(); if (dist(saucer2.x, saucer2.y, ships[i].laserposx, ships[i].laserposy) <30) { fail = true; } if (fail==false) { saucer2.display(); } }

if (fail == true) { if (explo<50) {//saucer explodes explo++; } fill(#F7710A); ellipse(saucer2.x, saucer2.y, explo, explo); fill(255); text("You lose! \nThe human race lives on", 250, 200); } 

} }

class Ship { int x; int y; Ship () { x = 250; y = 400; }

void move() { //WASD motion if (fail == false) { if (x>20) {//cannot move past left edge of screen if (key == 'a') { x = x-3; } } if (x<480) {//cannot move past right edge of screen if (key == 'd') { x = x +3; } } if (key == 's') { y = y+3; } if (key == 'w') { y = y-3; } } } void display() { noStroke(); fill(#393838); ellipse(x, y, 40, 40); fill(#676666); ellipse(x, y, 30, 30); fill(#CECECE); stroke(1); ellipse(x, y, 10, 10); } }

class Rock { float x; float y; float size; float speed; Rock () { x = random(20, 480); y = random(-500, 200); size = random(10, 30); speed = random(1, 2); } void move() { y = y + speed; }

void display() { noStroke(); fill(#6F4219); ellipse(x, y, size, size); } }

class Galaga { float x; float y; float speed = 1; float shoot; float laserposx; float laserposy; boolean shot = false; Galaga (int tempx, int tempy) { y = tempy; x = tempx; } void display() { fill(#6F6E6E); noStroke(); fill(#6F6E6E); ellipse(x, y, 30, 30); fill(0); rect(x, y+15, 15, 15); triangle(x-15, y, x+15, y, x, y-40); rectMode(CENTER); fill(255); ellipse(x, y, 10, 5); } void move() { y = y + .3; x = x + speed; if (x>480) { speed = -1 ; } if (x<20) { speed = 1 ; } if (y>540) { y = -15; } } void lasers() {

shoot = random(0, 201); if (shoot > 200 ) { shot = true; laserposy = y + 20; laserposx = x; } if (shot == true) { fill(255, 0, 0); rect(laserposx, laserposy, 4, 20); laserposy = laserposy + 2; } 

} }

submitted by /u/gishnu11
[link] [comments]

Programming for Artists