You now have two people (probably more) willing to help you, and there is absolutely nothing they can do to help you because no one knows what your goal or assignment is, or what you have working so far.
Immediate syntax concerns: 1) Don't put a semicolon between the parentheses following a function name and the brackets that surround that function's body. (No: void func();{} Yes: void func(){}). 2) Make sure you match opening brackets with closing ones. Where is drawbackground()'s closing bracket?
You've called a logs() function, but haven't defined it. You call a Froggy() function, but have defined it as froggy() (case matters).
Your background's rectangles only show up on half the screen because you have rectMode(CENTER) in setup(), yet appear to be defining rectangle as if CORNER mode were being used.
Many rectangles are only 600 pixels long, yet the window is 700 pixels wide. I suggest you adjust the size to 600 by 600.
You probably don't want the call to frameRate() in setup() either.
You call ellipseMode(CENTER), but draw no ellipses. You have a Carssetup() function commented out, which isn't meaningful. You have unused y and speed arrays.
You're got a lot of repetitive code to draw the yellow rectangles for the passing lanes. This is easily replaced by a for loop. My OCD kicked in and I have to make the spacing even too, so I shifted them over by 5 pixels. This was easy to do since the code used a loop (I didn't have to replace a bunch of numbers, only one!).
Calling functions that don't do anything, while useful for breaking things apart, is rather unnecessary. Everything can go in draw().
And with all that taken care of, we have a starting point:
//- Classes for Cars and Logs, to define what those objects are.
//- A class for the frog.
//- Class methods to move and draw those objects.
//- Code to add those objects at appropriate times.
//- Detect keyboard input.
//- Rectangle-rectangle collision detection.
//- Game states.
//- Lives and score counters, on-screen display.
There is a lot to do. Post some code attempting any of the above for more help.
Well i got my progress report and I'm an 38 in class which meas my frogger was due on the 15th of April and my Pac-man game was due on the 8th of this month and the exam game was due on the 20th.
The Exam Assignment is for me,the student to make a frogger game, one frog and many cars , goal to get to the other side.
So far I've got this,the only thing I've got correctly is the background. V
int x1=0,x2=0,x3=0,x4=0,x5=0;
void setup(){
size(600,600);
noStroke();
}
void draw(){
background(0);
background(0);
fill(57, 149, 58);
rect(0, 520, 600, 90);
fill(152, 149, 149);
rect(0, 500, 600, 20);
fill(57, 149, 58);
rect(0, 300, 600, 50);
fill(152, 149, 149);
rect(0, 290, 600, 10);
fill(152, 149, 149);
rect(0, 350, 600, 10);
fill(57, 149, 58);
rect(0, 100, 600, 50);
fill(152, 149, 149);
rect(0, 150, 600, 10);
fill(51, 155, 173);
rect(0, 50, 600, 60);
fill(57, 149, 58);
rect(0, 0, 600, 50);
fill(216, 245, 57);
for(int i=5; i<=width; i+=40){
rect(i, 425.5, 30, 10);
rect(i, 226, 30, 10);
}
}
//cars
for(int i=10; i > xxx.length; i++){
fill(250,10,10);
rect(xxx[i],yyy[i],70,30);
}
//Restart cars when they get to right side
if (xxx[i] >= width) {
xxx[i]=random(-500,0);
yyy[i]=random(0,height);
speedxx[i]=random(3,12);
for(int i=0; i < xxx.length; i++){
xxx[i]=xxx[i]+speedxx[i];
}
}
}
{
fill(30, 198, 68);{
ellipse(xx,yy,40,40);
//Keybored controll
if (keyPressed) {
//Control ellipse
if (keyCode==RIGHT)
xx=xx+3;
if (keyCode==LEFT)
xx=xx-3;
if (keyCode==DOWN)
yy=yy+3;
if (keyCode==UP)
yy=yy-3;
}
}
}
//Cars
//Variables
float userxxx=width/2, useryyy=height/2;
int i=1;
//Arrays for logs to move across screen in water
float xxx[] = new float[300];
float yyy[] = new float [300];
float speedxx [] = new float [300];
//Frog
int xx=300,yy=550;{
}
//Logs
//Variables
//float userx=width/2, usery=height/2;
//int i=1;
//Arrays for logs to move across screen in water
float x[] = new float [300];
float y[] = new float [300];
float speed [] = new float [300];
void drawlogs() {
//Logs
for(int i=10; i > x.length; i++){
fill(90,46,46);
rect(x[i],y[i],70,30);
}
//Restart logs when
//they get to right side
if (x[i] >= width) {
x[i]=random(-500,0);
y[i]=random(0,height);
speed[i]=random(3,12);
for(int i=0; i < x.length; i++){
x[i]=x[i]+speed[i];
}
}
}
The reason its so late is because well I'm a beginner at a college level and my teacher has taught me a lot but hasn't showed me how to do any of this information.Other than Arrays,collision, methods,menu's, ifs, and control structure.
Making this program drive me insane with anxiety of not know what the hell I'm doing.(sorry for the use of hell, it makes me upset to have stuff late)
Okay. I've formatted my code. My problem is that I haven't been able to make my Cars appear once I've added the arrays and loops.My main problem is making the other objects move besides the player.
I also dont quite understand the use of this segment along with he use of [i]. VV
if (x[i] >= width) {
x[i]=random(-500,0);
y[i]=random(0,height);
speed[i]=random(3,12);
for(int i=0; i < x.length; i++){
x[i]=x[i]+speed[i];
}
}
Your brackets are all over the place. In the Processing editor, press Ctrl + t to auto-format your code. Once you've done this, you'll realize that you have a for loop outside of any function! Also, I'd put all your global variables at the top.
Oh wait, the code outside of any function is a duplicate of what's inside drawLogs()... but labeled for cars, and uses xxx and yyy instead of xx and yy arrays. It's like you're trying to do logs and cars at the same time, without getting one working before the other.
I suggest you forget about using multiple arrays with different names for different objects, and instead step up your game and learn to encapsulate things into logical objects, using OOP. This means you should look up the keyword "class" in the reference.
Well I'm unsure about the carsetup in general since i used my friends car setup from their frogger because he managed to get it working.But now that I've tried to fix the numbers for my game it ain't working and my friends cant fix em'.
Also the way your explaining the arrays is a little confusing especially around this area.
Answers
sure, post your code
where are you stuck?
have you done OOP?
make one class Player, one Frog etc.
what are the other 2 assignments ?
You now have two people (probably more) willing to help you, and there is absolutely nothing they can do to help you because no one knows what your goal or assignment is, or what you have working so far.
it's a known game.....
If it's for an assignment, it's probably not an exact clone.
true.....
;-)
And there is a difference between helping and doing the assignment for OP. :P
Here is what i managed to do on my own. I've asked for help from my teacher but he is'nt much help,neither are my friend in class. :I
float y[] = new float [60]; float speed [] = new float [60]; void setup(){ frameRate(60); size(700,600); rectMode(CENTER); ellipseMode(CENTER); noStroke(); // Carssetup();
}
void draw(){ cars(); logs(); background(); Froggy(); }
void drawbackground() { //background background(0);
//Grass fill(57,149,58); rect(0,520,600,90);
//Side walk fill(152,149,149); rect(0,500,600,20);
//Middle grass and curb //Grass fill(57,149,58); rect(0,300,600,50);
//Curb#1 fill(152,149,149); rect(0,290,600,10);
//Curb#2 fill(152,149,149); rect(0,350,600,10);
//More grass fill(57,149,58); rect(0,100,600,50);
//Curb#3 fill(152,149,149); rect(0,150,600,10);
//Water fill(51,155,173); rect(0,50,600,60);
//Even more grass! fill(57,149,58); rect(0,0,600,50);
//Passing lanes fill(216,245,57); rect(0, 425.5, 30, 10); rect(40, 425.5, 30, 10); rect(80, 425.5, 30, 10); rect(120, 425.5, 30, 10); rect(160, 425.5, 30, 10); rect(200, 425.5, 30, 10); rect(240, 425.5, 30, 10); rect(280, 425.5, 30, 10); rect(320, 425.5, 30, 10); rect(360, 425.5, 30, 10); rect(400, 425.5, 30, 10); rect(440, 425.5, 30, 10); rect(480, 425.5, 30, 10); rect(520, 425.5, 30, 10); rect(560, 425.5, 30, 10); rect(600, 425.5, 30, 10);
//Passing lanes#2 rect(0, 226, 30, 10); rect(40, 226, 30, 10); rect(80, 226, 30, 10); rect(120, 226, 30, 10); rect(160, 226, 30, 10); rect(200, 226, 30, 10); rect(240, 226, 30, 10); rect(280, 226, 30, 10); rect(320, 226, 30, 10); rect(360, 226, 30, 10); rect(400, 226, 30, 10); rect(440, 226, 30, 10); rect(480, 226, 30, 10); rect(520, 226, 30, 10); rect(560, 226, 30, 10); rect(600, 226, 30, 10);
//void froggy();{
//}
//void cars();{ // }
Also bare with the disorganization,Im new at this.
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
Immediate syntax concerns: 1) Don't put a semicolon between the parentheses following a function name and the brackets that surround that function's body. (No: void func();{} Yes: void func(){}). 2) Make sure you match opening brackets with closing ones. Where is drawbackground()'s closing bracket?
You've called a logs() function, but haven't defined it. You call a Froggy() function, but have defined it as froggy() (case matters).
Your background's rectangles only show up on half the screen because you have rectMode(CENTER) in setup(), yet appear to be defining rectangle as if CORNER mode were being used.
Many rectangles are only 600 pixels long, yet the window is 700 pixels wide. I suggest you adjust the size to 600 by 600.
You probably don't want the call to frameRate() in setup() either.
You call ellipseMode(CENTER), but draw no ellipses. You have a Carssetup() function commented out, which isn't meaningful. You have unused y and speed arrays.
You're got a lot of repetitive code to draw the yellow rectangles for the passing lanes. This is easily replaced by a for loop. My OCD kicked in and I have to make the spacing even too, so I shifted them over by 5 pixels. This was easy to do since the code used a loop (I didn't have to replace a bunch of numbers, only one!).
Calling functions that don't do anything, while useful for breaking things apart, is rather unnecessary. Everything can go in draw().
And with all that taken care of, we have a starting point:
Or, if you were to save the result of that as bg.PNG via save(), the code becomes:
Now, you want to make a frogger game?
You'll probably need:
There is a lot to do. Post some code attempting any of the above for more help.
As our academics friends likes to say: :)
Break it in pieces, work each piece separated and when you got them working, put it all together.
one sketch - draw the "board"
other - make a "frog"that can be driven by keys make a collision test for it…
other - make cars that travels across screen modify this one to draw logs instead
and so on…
Later, try to put all together.
Ask along the way… Also Google is your friend.
well, honestly, how much days have you left?
have you done OOP?
make one class Player, one Frog etc.
really, when time is pressing just say so
Re: Chrisir
Well i got my progress report and I'm an 38 in class which meas my frogger was due on the 15th of April and my Pac-man game was due on the 8th of this month and the exam game was due on the 20th.
Also can you define OP?
Re:TFGuy44
yes I'm wanting to make a Frogger game for a class assignment.
OP = original / first post in a forum thread
ah, OOP, you mean
that's object oriented programming like when you use classes and objects
TFGuy wrote:
so, what is the exact assignment??
one frog and many cars?
TfGuy has posted a lot of code and tasks.
Have you done anything of these tasks?
The Exam Assignment is for me,the student to make a frogger game, one frog and many cars , goal to get to the other side.
So far I've got this,the only thing I've got correctly is the background. V
The reason its so late is because well I'm a beginner at a college level and my teacher has taught me a lot but hasn't showed me how to do any of this information.Other than Arrays,collision, methods,menu's, ifs, and control structure. Making this program drive me insane with anxiety of not know what the hell I'm doing.(sorry for the use of hell, it makes me upset to have stuff late)
go back.
edit your post,
format your code properly
2 empty lines before and after the code
select the code with the mouse
hit ctrl-o
read what tfguy and others have written
write it
ask concrete questions like I've tried A, wanted top achieve this and my problem is that....
plan 3 free days for this
Okay. I've formatted my code. My problem is that I haven't been able to make my Cars appear once I've added the arrays and loops.My main problem is making the other objects move besides the player. I also dont quite understand the use of this segment along with he use of [i]. VV
Your brackets are all over the place. In the Processing editor, press Ctrl + t to auto-format your code. Once you've done this, you'll realize that you have a for loop outside of any function! Also, I'd put all your global variables at the top.
Oh wait, the code outside of any function is a duplicate of what's inside drawLogs()... but labeled for cars, and uses xxx and yyy instead of xx and yy arrays. It's like you're trying to do logs and cars at the same time, without getting one working before the other.
I suggest you forget about using multiple arrays with different names for different objects, and instead step up your game and learn to encapsulate things into logical objects, using OOP. This means you should look up the keyword "class" in the reference.
It's already late? How much later can it be?
https://www.processing.org/tutorials/objects/
Here's an example object...........
Re:TfGuy44
Its already late and i have until the 19th of June to hand in any late work.
so...
get to work...
Re:Chrisir
Okay okay I'm workin'!
;-)
Re:Chrisir
:)
ok, I see you don't want to use classes or OOP / Objects
That's ok for now I guess
The arrays
you have the arrays x and y and speed
I am not sure you get what you want here
the idea is that these are 3 parallel lists (imagine 3 shopping lists lying next to each other)
ok, the first car (lets call it CARL) is described by the stuff in the first line:
the first line in the first list is CARLs x
the first line in the 2nd list is CARLs y
the first line in the 3rd list is CARLs speed
so to display CARL say draw car at first line in first list and at y being first line 2nd list :
well done. you got that!
rect(x[1], y[1], 40, 40);
or ratherrect(x[0], y[0], 40, 40);
draws CARLNext car is BOB, it's at
rect(x[1], y[1], 40, 40);
Question
but in carsetup, why do you have 60 cars and place the first 10 cars at the same position?
moreover, in carsetup you start each for-loop at 0 so you write over the old data from the first for-loops
re-think that
or give your reasons
;-)
in
this is stopping it all!!!!!!!!!!!!!!!!!!!!!
two times.....................
you could make them reappear
Well I'm unsure about the carsetup in general since i used my friends car setup from their frogger because he managed to get it working.But now that I've tried to fix the numbers for my game it ain't working and my friends cant fix em'. Also the way your explaining the arrays is a little confusing especially around this area.
the first line in the first list is CARLs x
the first line in the 2nd list is CARLs y
the first line in the 3rd list is CARLs speed
err.....
list one is x[]
list 2 is y[]
list 3 is speed[]
in your code
I want you to understand this and your code.
one car is described in three lists
Carl: 1st line in all lists
Bob: 2nd line in all lists
understand the difference between list and line (line number) here
it's useless to copy code from a friend you don't understand
You have a point. I'm still confused about lists and lines.
the idea is that these are 3 parallel lists (imagine 3 shopping lists lying next to each other)
I wrote some code to you could make them reappear.
that was wrong. ouch
anyway.
I fixed your program and can lead you through
I also understand your carsetup now:
you got 6 for-loops there, one for each lane, so the y can be different
but as I said, don't start with 0 every time
better:
see?
the idea is that these are 3 parallel lists (imagine 3 shopping lists lying next to each other)
to draw first car CARL you would look into the first line of all 3 lists
then Bob, same lists, but next line of them
also in carsetup()
some cars should go from left to right, others from right to left
now you have 10 cars right on top of each other
not good
you could say x[i]= i*40;
or so
Okay....this is a lot to take in. :-?
??
come on, you're almost there
also, what are the other 2 assignments??
or in carsetup() just get rid of all for-loops and change the rest accordingly
Okay....now my program says"Unexpected void token"