Hi everyone so I was following an online tutorial to create a vertical shooter game this was the code given:
So this easily creates a pretty basic vertical shooter, I already modified several things to make the game more attractive but I wanted to ask if it was possible that what you see displayed isnt the complete size and that if you moved to the left or you would start like scrolling through through other part of the canvas. Something like have a canvas with a size 1000x1000 but only 400x400 is displayed, so if you move a bit to the left the display is still 400x400 but you see another part of the canvas.
I would also like to know how to make the game scroll upwards, as if you were moving upwards or something like 1942 for example.
Dunno if this is too confusing but tried to explain it the best that I could.
Thanks to everyone that is able to help me and sorry to bother you
PFont fontA;
int sphereDiameter = 10;
boolean shoot = false;
int randx()
{
return int(random(600));
}
int[] sphereXCoords = { randx(), randx(), randx(), randx(), randx() };
int[] sphereYCoords = { 0, 0, 0, 0, 0 };
void setup()
{
size(600,620);
}
void draw()
{
background(0);
fill(color(0,255,0));
stroke(color(0,255,0));
triangle(mouseX-8, 580, mouseX+8, 580, mouseX, 565);
fill(color(255,0,0));
stroke(color(255,0,0));
if(shoot==true)
{
sphereKiller(mouseX);
shoot = false;
}
sphereDropper();
gameEnder();
}
void mousePressed()
{
shoot = true;
}
void sphereDropper()
{
stroke(255);
fill(255);
for (int i=0; i<5; i++)
{
ellipse(sphereXCoords[i], sphereYCoords[i]++,
sphereDiameter, sphereDiameter);
}
}
void sphereKiller(int shotX)
{
boolean hit = false;
for (int i = 0; i < 5; i++)
{
if((shotX >= (sphereXCoords[i]-sphereDiameter/2)) &&
(shotX <= (sphereXCoords[i]+sphereDiameter/2)))
{
hit = true;
line(mouseX, 565, mouseX, sphereYCoords[i]);
ellipse(sphereXCoords[i], sphereYCoords[i],
sphereDiameter+25, sphereDiameter+25);
sphereXCoords[i] = randx();
sphereYCoords[i] = 0;
}
}
if(hit == false)
{
line(mouseX, 565, mouseX, 0);
}
}
void gameEnder()
{
for (int i=0; i< 5; i++)
{
if(sphereYCoords[i]==600)
{
fill(color(255,0,0));
noLoop();
}
}
}
So this easily creates a pretty basic vertical shooter, I already modified several things to make the game more attractive but I wanted to ask if it was possible that what you see displayed isnt the complete size and that if you moved to the left or you would start like scrolling through through other part of the canvas. Something like have a canvas with a size 1000x1000 but only 400x400 is displayed, so if you move a bit to the left the display is still 400x400 but you see another part of the canvas.
I would also like to know how to make the game scroll upwards, as if you were moving upwards or something like 1942 for example.
Dunno if this is too confusing but tried to explain it the best that I could.
Thanks to everyone that is able to help me and sorry to bother you
1