this code is pretty long... the paint method is near the top... the rest is just the game's engine and whatnot. right now i was just experimenting with getting it to read anything more complicated than a boolean or a int in the paint statement. ive tried instantiating a 2D array, array, and string outside of the paint statement... but if i attempt to read any of them in the statement, the applet freezes up.
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
//import java.awt.geom.Arc2D;
import java.applet.*;
//import java.util.*;
import java.math.*;
public class Souper3 extends Applet implements KeyListener,Runnable
{
double dx,dy;
private Thread th;
private Image dbImage;
private Graphics dbg;
Image chrimage,block,block2,wizrunL1,wizrunL2,wizrunL3,wizrunL4,wizrunR1,wizrunR2,wizrunR3,wizrunR4,blocksolid;
int charCol,charRow,x,y,runValPx,jumpValPx,xVelPx,yVelPx,charx,chary,anim,centerX,centerY,tempt,woot;
char c;
Font font = new Font("Courier New", Font.BOLD, 14);
boolean up,down,left,right,space,goingUp,omg,animL,land,inway,jumpingF,temp,jumpingR,jumpingL,jumpingU,grounded,falling,kill,jump;
chr chr;
int[][] level,levelTrack;
double xVel,yVel,runValue,jumpValue;
public Souper3(){}
public void init()
{
addKeyListener(this);
up=false;down=false;left=false;right=false;space=false;jumpingU=false;jumpingF=false;omg=false;falling=false;
animL=false;land=false;grounded=true;kill=false;jump=false;
x=-256;y=-512;
charx=192;chary=320;
anim=1;
xVelPx = 0;
xVel = 0.0;
chrimage = getImage(getCodeBase(), "wizard.gif");
wizrunR1 = getImage(getCodeBase(), " wizrunR1.gif");
wizrunR2 = getImage(getCodeBase(), " wizrunR2.gif");
wizrunR3 = getImage(getCodeBase(), "wizrunR3.gif");
wizrunR4 = getImage(getCodeBase(), "wizrunR4.gif");
wizrunL1 = getImage(getCodeBase(), " wizrunL1.gif");
wizrunL2 = getImage(getCodeBase(), " wizrunL2.gif");
wizrunL3 = getImage(getCodeBase(), "wizrunL3.gif");
wizrunL4 = getImage(getCodeBase(), "wizrunL4.gif");
block = getImage(getCodeBase(), " block.gif");
block2 = getImage(getCodeBase(), "2block.gif");
blocksolid = getImage(getCodeBase(), "blocksolid.gif");
}
public void start()
{
th = new Thread(this);
th.start();
}
public void stop(){}
public void destroy(){}
public void run()
{
Thread.currentThread ().setPriority( Thread.MIN_PRIORITY );
int[][] level = {
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,4,0,0,0,1,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,4,0,0,0,0,0,0,1,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,4,4,0,0,0,0,1,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,4,0,0,4,4,0,0,0,0,0,0,1,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,4,0,0,0,4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,4,4,4,4,},
{4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,},
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,}};
while (true)
{
movement(level);
repaint();
try{ Thread.sleep(20);}catch (InterruptedException ex) { }
Thread.currentThread ().setPriority(Thread.MAX_PRIORITY);
}
}
public void keyPressed(KeyEvent e)
{
int keyCode = e.getKeyCode();
switch (keyCode)
{
case KeyEvent.VK_UP:
up = true;
break;
case KeyEvent.VK_DOWN:
down = true;
break;
case KeyEvent.VK_LEFT:
left = true;
break;
case KeyEvent.VK_RIGHT:
right = true;
break;
case KeyEvent.VK_SPACE:
space = true;
break;
case KeyEvent.VK_ENTER:
//cb = true;
break;
}
}
public void keyReleased(KeyEvent e)
{
int keyCode = e.getKeyCode();
switch (keyCode)
{
case KeyEvent.VK_UP:
up = false;
break;
case KeyEvent.VK_DOWN:
down = false;
break;
case KeyEvent.VK_LEFT:
left = false;
break;
case KeyEvent.VK_RIGHT:
right = false;
break;
case KeyEvent.VK_SPACE:
space = false;
break;
case KeyEvent.VK_ENTER:
//cb = false;
break;
}
}
public void keyTyped(KeyEvent e){}
public void paint(Graphics g)
{
int[][] level = {
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,4,0,0,0,1,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,4,0,0,0,0,0,0,1,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,4,4,0,0,0,0,1,0,0,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,4,0,0,4,4,0,0,0,0,0,0,1,4,4,4,4,},
{4,4,4,4,0,0,0,0,0,0,0,4,0,0,0,4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,4,4,4,4,},
{4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,},
{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,}};
super.paint(g);
Graphics2D g2 = (Graphics2D)g;
if((animL==true)&&(anim==1)){g2.drawImage(wizrunL1,192,320,64,64, this);}
if((animL==true)&&(anim==2)){g2.drawImage(wizrunL2,192,320,64,64, this);}
if((animL==true)&&(anim==3)){g2.drawImage(wizrunL3,192,320,64,64, this);}
if((animL==true)&&(anim==4)){g2.drawImage(wizrunL4,192,320,64,64, this);}
if((animL==false)&&(anim==1)){g2.drawImage (wizrunR1,192,320,64,64, this);}
if((animL==false)&&(anim==2)){g2.drawImage(wizrunR2,192,320,64,64, this);}
if((animL==false)&&(anim==3)){g2.drawImage(wizrunR3,192,320,64,64, this);}
if((animL==false)&&(anim==4)){ g2.drawImage(wizrunR4,192,320,64,64, this);}
g.drawString("charRow = " + charRow,20,20);
g.drawString("charCol = " + charCol,20,30);
g.drawString("centerX = " + centerX,20,40);
g.drawString ("centerY = " + centerY,20,50);
g.drawString("tempt = " + tempt,20,60);
g.drawString("x = " + x,20,70);
g.drawString("y = " + y,20,80);
if(omg==true){g.drawString("omg",20,90);}
g.drawString("runValPx = " + runValPx,20,100);
g.drawString("grounded = " + grounded,20,110);
g.drawString("falling = " + falling,20,120);
g.drawString("level[((centerY+32)/64)][((centerX+runValPx+32)/64)] = " + level[((centerY+32)/64)][((centerX+runValPx+32)/64)],20,130);
g.drawString("level[((centerY)/64)][((centerX+runValPx)/64)] = " + level[centerY/64][(centerX+runValPx)/64],20,140);
g.drawString("woot = " + woot,20,150);
setBackground( Color.white );
for(int row=0;row<16;row++)
{
for(int col=0;col<36;col++)
{
if(level[row][col]==1){
g2.drawImage(block,(x+(col*64)),(y+(row*64)),64,64,this);}
if(level[row][col]==2){
g2.drawImage(block2,(x+(col*64)),(y+(row*64)),64,64,this);}
if(level[row][col]==4){
g2.drawImage(blocksolid,(x+(col*64)),(y+(row*64)),64,64,this);}
}}
//g2.drawImage(chrimage,0,0,( chrimage.getWidth (this)),(chrimage.getHeight(this)), this);
g2.setColor(Color.BLACK );
g2.setFont(font);
repaint();
}
public void update(Graphics g)
{
if (dbImage == null)
{
dbImage = createImage( this.getSize ().width, this.getSize().height);
dbg = dbImage.getGraphics ();
}
g.drawImage (dbImage, 0, 0, this);
dbg.setColor(getBackground());
dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
dbg.setColor (getForeground());
paint(dbg);
}
public void movement(int[][] level){
trackpos(level);
gravity(level);
if((right==true)&&(grounded==true)&&(falling==false)&&(moveable('R',level))){run('R');}
if((left==true)&&(grounded==true)&&(falling==false)&&(moveable('L',level))){run('L');}
if((right==true)&&(grounded==false)&&(falling==true)&&(moveable('A',level))){run('R');}
if((left==true)&&(grounded==false)&&(falling==true)&&(moveable('B',level))){run('L');}
if((space==true)&&(jumpable(level))){jump();}
move();
}
public void trackpos(int[][] level){
centerX = (-1*x) + 224;
centerY = (-1*y) + 352;
charRow = (centerY/64);
charCol = (centerX/64);
runValue = 0.47;
jumpValue = 0.6;
runValPx=((int)(64*((runValue)/1.83)));
jumpValPx=((int)(64*((jumpValue)/1.83)));
//if((level[((centerY+33)/64)][charCol]>0)&&(level[((centerY+33)/64)][charCol]<65)){grounded=true;}
if((((level[((centerY+33)/64)][charCol]>0)&&(level[((centerY+33)/64)][charCol]<65))||((level[((centerY+33)/64)][((centerX+13)/64)]>0)&&(level[((centerY+33)/64)][((centerX+13)/64)]<65))||((level[((centerY+33)/64)][((centerX-13)/64)]>0)&&(level[((centerY+33)/64)][((centerX-13)/64)]<65)))){grounded=true;}
if((level[((centerY+33)/64)][charCol]==0)&&(level[((centerY+32)/64)][((centerX+20)/64)]==0)&&(level[((centerY+33)/64)][((centerX-20)/64)]==0)){grounded=false;}
//if((level[((centerY+33)/64)][charCol]==0)){grounded=false;}
}
public void gravity(int[][] level){
if((((level[((centerY-25)/64)][charCol]>0)&&(level[((centerY-25)/64)][charCol]<65))||((level[((centerY-25)/64)][((centerX+13)/64)]>0)&&(level[((centerY-25)/64)][((centerX+13)/64)]<65))||((level[((centerY-25)/64)][((centerX-13)/64)]>0)&&(level[((centerY-25)/64)][((centerX-13)/64)]<65)))&&(jump==true)){yVel=0.0;jump=false;}
if((grounded==false)&&(falling==false)){falling=true;yVel=-0.05;}
if((grounded==false)&&(falling==true)&&(yVel>- 0.7)){yVel=yVel-0.05;}
yVelPx=((int)(64*((yVel)/1.83)));
if(yVelPx>0){woot=centerY;}
kill=false;
if((grounded==true)&&(falling==true)){
for(tempt=1;tempt<65;tempt++){
if(((centerY+tempt)%64)==0)
{
yVelPx=(-1*tempt)+32;
kill=true;
grounded=true;
falling=false;
}}}
}
public boolean moveable(char c, int[][] level){
temp=true;
//R = check right side on ground
//L = check left side on ground
//A = check top right, bottom right, and right side in air
//B = check top left, bottom left, and left side in air
if((c=='R')&&(level[charRow][((centerX+runValPx+25)/64)]>0)&&(level[charRow][((centerX+runValPx+25)/64)]<65)){temp=false;}
if((c=='L')&&(level[charRow][((centerX-runValPx-25)/64)]>0)&&(level[charRow][((centerX-runValPx-25)/64)]<65)){temp=false;}
if((c=='A')&&(level[charRow][((centerX+runValPx+32)/64)]>0)&&(level[charRow][((centerX+runValPx+32)/64)]<65)){
if(((level[((centerY+32)/64)][((centerX+runValPx+32)/64)]>0)&&(level[((centerY+32)/64)][((centerX+runValPx+32)/64)]<65))||((level[((centerY-32)/64)][((centerX+runValPx+32)/64)]>0)&&(level[((centerY-32)/64)][((centerX+runValPx+32)/64)]<65)))
{temp=false;omg=true;}}
if((c=='B')&&(level[charRow][((centerX-runValPx-32)/64)]>0)&&(level[charRow][((centerX-runValPx-32)/64)]<65)){
if(((level[((centerY+32)/64)][((centerX-runValPx-32)/64)]>0)&&(level[((centerY+32)/64)][((centerX-runValPx-32)/64)]<65))||((level[((centerY-32)/64)][((centerX-runValPx-32)/64)]>0)&&(level[((centerY-32)/64)][((centerX-runValPx-32)/64)]<65)))
{temp=false;omg=true;}}
return temp;}
public void run(char c){
if(c=='R'){xVel=(-1*runValue);animR();}
if(c=='L'){xVel=runValue;animL();}
xVelPx=((int)(64*((xVel)/1.83)));
}
public boolean jumpable(int[][] level){
temp=true;
if((level[((centerY+jumpValPx)/64)][charCol]>0)&&(level[((centerY+jumpValPx)/64)][charCol]<65)){temp=false;}
return temp;
}
public void jump(){
if((grounded==true)&&(falling==false)){
yVel=jumpValue;
grounded=false;
falling=true;
jump=true;
yVelPx=((int)(64*((yVel)/1.83)));}
}
public void move(){
x = x + xVelPx;
xVelPx = 0;
xVel = 0.0;
y = y + yVelPx;
if(kill==true){yVelPx=0;yVel= 0.0;kill=false;}
}
public void animL(){
animL=true;
if(anim!=4){anim++;}
if(anim==4){anim=1;}
}
public void animR(){
animL=false;
if(anim!=4){anim++;}
if(anim==4){anim=1;}}}
I'm way over my head here so my free advice is worth every cent, but one thing that doesn't look right to me is that you have a call to repaint from inside a paint procedure. I think that this is not needed and might be dangerous. Is there a risk for a circular call there that may never end? To be honest, I'm not sure, but you might want to look into it. Hopefully an AWT guru will give you a more definitive answer soon.
Good luck!
/Pete
i am just trying to make the paint method read arrays that are not instantiated in the paint method. i attempted taking out the repaint inside the paint statement, but this did nothing. ive also tried instantiating the arrays inside of various applet methods to no avail.
i realize this code looks like a big mess. oh well. ive completely rewritten this base code 3 times now to get it into the most efficient form possible. the code i posted works flawlessly and smoothly in BlueJ running JDK 1.6.0
is there any rule about paint methods not being able to read arrays from outside of themselves?
> i am just trying to make the paint method read arrays
> that are not instantiated in the paint method. i
> attempted taking out the repaint inside the paint
> statement, but this did nothing.
No it does a whole lot of something..
For starters it then updates with the key-presses. It also does not
consume 99% of processor resources constantly.
I suspect you are testing in your browser and not with appletviewer. You
should use appletviewer, otherwise you must shutdown and restart your
browser each and everytime you recompile. The browser "caches" the
applet once it is loaded and will not reflect changes you make until
you restart.
dang youre right
i have been using applet viewer, but i didnt realize
that the repaint() statement in the paint() method was totally
raping my CPU until i just brought up task manager.
also, the paint() method and whatnot were developed simply
by looking at other people's code. i dont have a total grasp of
what everything the paint() method
does, just a grasp that it works. sorry to present
you with problems like the aforementioned.
however, my teacher
has truly done nothing more to teach us than give us word documents
for lessons and hand out tests every few weeks.
he is a funny guy, but he does not know a thing about java programming.
i enjoy coding and so i started persuing this game for fun.
the majority of the class has started playing LAN Quake 3 deathmatch
games and completely forgotten about the course.
i hope someone can help me with this though as ive been stuck on it for
several days now. its very frustrating
> dang youre right
>
> i have been using applet viewer, but i didnt realize
> that the repaint() statement in the paint() method
> was totally
> raping my CPU until i just brought up task manager.
>
> also, the paint() method and whatnot were developed
> simply
> by looking at other people's code. i dont have a
> total grasp of
> what everything the paint() method
> does, just a grasp that it works. sorry to present
> you with problems like the aforementioned.
>
> however, my teacher
> has truly done nothing more to teach us than give us
> word documents
> for lessons and hand out tests every few weeks.
> he is a funny guy, but he does not know a thing about
> java programming.
>
> i enjoy coding and so i started persuing this game
> for fun.
> the majority of the class has started playing LAN
> Quake 3 deathmatch
> games and completely forgotten about the course.
>
> i hope someone can help me with this though as ive
> been stuck on it for
> several days now. its very frustrating
Suggestion 1)
I have to be honest with you here. What you need is in person teaching.
Teaching by forum is not effective for many reasons, it's not great for
communicating what your problems are, it's slow, etc.
Some guidance can be given by forum but basic teaching is really a no
go.
Now I am glad that you have an interest in programming, it's great to
see. But I think you should really explore what kind of in-person options
you might have (see 2 and 3). I am not saying this to be mean, I am
saying this to be pragmatic about it. Learning this way will be VERY
frustrating for you and probably not very productive and that seems a
great shame given that you have interest.
2) Did you try and talk to the teacher and show them what you are doing
on your own? It might inspire the teacher to help you more one-on-one
if they see that you have an actual interest in the subject.
3) Failing that talk to your parents about hiring a tutor or teacher
part-time to help you learn. A good university level student would be
able, I think, to help you get a more solid foundation and it wouldn't have
to be very expensive. Plus parents always find a way pretty much to find
money when it comes to investing in their child's education, especially
when the education is in a field where the child has shown interest.
I mean I can point you at some tutorials and you can see what you can
do. I have seen people try this before and it just tends not to work out
very well.
Good luck to you with whatever route you choose.
I've shown the teacher but he doesn't even know anything about applets or
the graphics class. Its ridiculous, I know, but its high school.
The requirements for AP Java don't mention what I'm working on at all. Next
fall I will be starting at the community college, but unfortunately they do
not offer advanced Java in the fall semester. So I'll be starting on C++ then.
Hopefully I'll get a chance to start an advanced Java course in January '08!
I'll be starting ASM then, too. Mmmm hexadecimals.
Fortunately, I do know some people who have helped me here and there.
I guess, however that the methods they have shown me are not entirely
the most efficient (as I have just discovered, hahaha). Until I figure this
out though, I feel like further development of this code will only
be counter productive.
If you can offer me a simple solution I would love you forever. However,
tutorials or whatnot sound good too.
Thanks a lot for taking the time. I really appreciate it.
> If you can offer me a simple solution I would love
> you forever.
Sorry, I don't think a simple solution is forthcoming. I think the most
direct comment I would make is again that you need more than one
class. Break the code down into smaller pieces. That's really the
guiding principal to all programming and OO programming even
moreso.
>However,
> tutorials or whatnot sound good too.
>
This is a fairly time-honoured list of resources that have helped others
and should be able to help you to. Start smaller on the design side of
things and you should be able to make a new program that does
what you want one heck of a lot easier.
Tip: You'll know that you're beginning to learn something when you look
at some of the code you have written now and go "What in the holy heck
was I thinking there?!?". :) This happens to everyone. It's just an
unavoidable part of the learning process.
[url=http://java.sun.com/docs/books/tutorial/ ]Sun's basic Java tutorial[/url]
[url=http://java.sun.com/learning/new2java/index.html ]Sun's New To Java Center[/url]. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
[url=http://javaalmanac.com ]http://javaalmanac.com [/url]. A couple dozen code examples that supplement [url=http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance ]The Java Developers Almanac[/url].
[url=http://www.jguru.com ]jGuru[/url]. A general Java resource site. Includes FAQs, forums, courses, more.
[url=http://www.javaranch.com ]JavaRanch[/url]. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's [url=http://mindview.net/Books/DownloadSites ]Thinking in Java[/url] (Available online.)
Joshua Bloch's [url=http://www.amazon.co.uk/exec/obidos/Author=Bloch,%20Josh ]Effective Java[/url]
most teachers are pretty good if students show an interest.
Most students are afraid to show an interest because they'll be seen as "teachers' pets" and loose "coolness" with the "chicks"...
Your teacher is most likely the same as most, disgusted and disillusioned by year after year of trying to get a classroom full of disinterested kids who can't be bothered to do more than the absolute minimum to get a passing grade (and would prefer to cheat their way out of doing even that) and is expecting no more from you.