Commit 4bd4c477 authored by Paul Tvete's avatar Paul Tvete

untabify

Leading spaces are just so much easier to work with.
parent a4dc0fcf
......@@ -26,35 +26,35 @@ TARGET = t14
.SUFFIXES: .cpp
.cpp.o:
$(CC) -c $(CFLAGS) -I$(INCDIR) $<
$(CC) -c $(CFLAGS) -I$(INCDIR) $<
####### Build rules
all: $(TARGET)
$(TARGET): $(OBJECTS) $(OBJMETA)
$(CC) $(OBJECTS) $(OBJMETA) -o $(TARGET) $(LFLAGS) -lm
$(CC) $(OBJECTS) $(OBJMETA) -o $(TARGET) $(LFLAGS) -lm
depend:
@makedepend -I$(INCDIR) $(SOURCES) 2> /dev/null
@makedepend -I$(INCDIR) $(SOURCES) 2> /dev/null
showfiles:
@echo $(HEADERS) $(SOURCES) Makefile
@echo $(HEADERS) $(SOURCES) Makefile
clean:
rm -f *.o *.bak *~ *% #*
rm -f $(SRCMETA) $(TARGET)
rm -f *.o *.bak *~ *% #*
rm -f $(SRCMETA) $(TARGET)
####### Meta classes
mlcdrang.cpp: lcdrange.h
$(MOC) -o $@ lcdrange.h
$(MOC) -o $@ lcdrange.h
mcannon.cpp: cannon.h
$(MOC) -o $@ cannon.h
$(MOC) -o $@ cannon.h
mgamebr.cpp: gamebrd.h
$(MOC) -o $@ gamebrd.h
$(MOC) -o $@ gamebrd.h
# DO NOT DELETE THIS LINE -- make depend depends on it.
......@@ -30,11 +30,11 @@ CannonField::CannonField( QWidget *parent, const char *name )
void CannonField::setAngle( int degrees )
{
if ( degrees < 5 )
degrees = 5;
degrees = 5;
if ( degrees > 70 )
degrees = 70;
degrees = 70;
if ( ang == degrees )
return;
return;
ang = degrees;
repaint( cannonRect(), FALSE );
emit angleChanged( ang );
......@@ -43,9 +43,9 @@ void CannonField::setAngle( int degrees )
void CannonField::setForce( int newton )
{
if ( newton < 0 )
newton = 0;
newton = 0;
if ( f == newton )
return;
return;
f = newton;
emit forceChanged( f );
}
......@@ -53,7 +53,7 @@ void CannonField::setForce( int newton )
void CannonField::shoot()
{
if ( shooting )
return;
return;
timerCount = 0;
shoot_ang = ang;
shoot_f = f;
......@@ -65,22 +65,22 @@ void CannonField::newTarget()
{
static bool first_time = TRUE;
if ( first_time ) {
first_time = FALSE;
QTime midnight( 0, 0, 0 );
srand( midnight.secsTo(QTime::currentTime()) );
first_time = FALSE;
QTime midnight( 0, 0, 0 );
srand( midnight.secsTo(QTime::currentTime()) );
}
erase( targetRect() );
target = QPoint( 200 + rand() % 190,
10 + rand() % 255 );
10 + rand() % 255 );
repaint( targetRect() );
}
void CannonField::setGameOver()
{
if ( gameEnded )
return;
return;
if ( shooting )
stopShooting();
stopShooting();
gameEnded = TRUE;
repaint();
}
......@@ -88,7 +88,7 @@ void CannonField::setGameOver()
void CannonField::restartGame()
{
if ( shooting )
stopShooting();
stopShooting();
gameEnded = FALSE;
repaint();
}
......@@ -101,15 +101,15 @@ void CannonField::timerEvent( QTimerEvent * )
QRect shotR = shotRect();
if ( shotR.intersects( targetRect() ) ) {
stopShooting();
emit hit();
return;
stopShooting();
emit hit();
return;
}
if ( (shotR.x() > width() || shotR.y() > height()) ||
shotR.intersects(barrierRect()) ) {
stopShooting();
emit missed();
return;
shotR.intersects(barrierRect()) ) {
stopShooting();
emit missed();
return;
}
repaint( shotR, FALSE );
}
......@@ -121,18 +121,18 @@ void CannonField::paintEvent( QPaintEvent *e )
p.begin( this );
if ( updateR.intersects( cannonRect() ) )
paintCannon( &p );
paintCannon( &p );
if ( updateR.intersects( barrierRect() ) )
paintBarrier( &p );
paintBarrier( &p );
if ( gameEnded ) {
p.setPen( black );
p.setFont( QFont( "Courier", 48, QFont::Bold ) );
p.drawText( rect(), AlignCenter, "Game Over" );
p.setPen( black );
p.setFont( QFont( "Courier", 48, QFont::Bold ) );
p.drawText( rect(), AlignCenter, "Game Over" );
} else {
if ( shooting && updateR.intersects( shotRect() ) )
paintShot( &p );
if ( updateR.intersects( targetRect() ) )
paintTarget( &p );
if ( shooting && updateR.intersects( shotRect() ) )
paintShot( &p );
if ( updateR.intersects( targetRect() ) )
paintTarget( &p );
}
p.end();
}
......@@ -140,20 +140,20 @@ void CannonField::paintEvent( QPaintEvent *e )
void CannonField::mousePressEvent( QMouseEvent *e )
{
if ( e->button() != LeftButton )
return;
return;
if ( barrelHit( e->pos() ) )
barrelPressed = TRUE;
barrelPressed = TRUE;
}
void CannonField::mouseMoveEvent( QMouseEvent *e )
{
if ( !barrelPressed )
return;
return;
QPoint pnt = e->pos();
if ( pnt.x() <= 0 )
pnt.setX( 1 );
pnt.setX( 1 );
if ( pnt.y() >= height() )
pnt.setY( height() - 1 );
pnt.setY( height() - 1 );
double rad = atan( ((double) rect().bottom() - pnt.y()) / pnt.x() );
setAngle( qRound ( rad*180/3.14159265 ) );
}
......@@ -161,7 +161,7 @@ void CannonField::mouseMoveEvent( QMouseEvent *e )
void CannonField::mouseReleaseEvent( QMouseEvent *e )
{
if ( e->button() == LeftButton )
barrelPressed = FALSE;
barrelPressed = FALSE;
}
void CannonField::stopShooting()
......
......@@ -87,14 +87,14 @@ GameBoard::GameBoard( QWidget *parent, const char *name )
void GameBoard::resizeEvent( QResizeEvent * )
{
frame->resize( width() - frame->x() - 10,
height() - frame->y() - 10 );
height() - frame->y() - 10 );
cannonField->resize( frame->width() - 4, frame->height() - 4 );
}
void GameBoard::fire()
{
if ( cannonField->gameOver() || cannonField->isShooting() )
return;
return;
shotsLeft->display( shotsLeft->intValue() - 1 );
cannonField->shoot();
}
......@@ -103,15 +103,15 @@ void GameBoard::hit()
{
hits->display( hits->intValue() + 1 );
if ( shotsLeft->intValue() == 0 )
cannonField->setGameOver();
cannonField->setGameOver();
else
cannonField->newTarget();
cannonField->newTarget();
}
void GameBoard::missed()
{
if ( shotsLeft->intValue() == 0 )
cannonField->setGameOver();
cannonField->setGameOver();
}
void GameBoard::newGame()
......
......@@ -28,9 +28,9 @@ void LCDRange::init()
lcd = new QLCDNumber( 2, this, "lcd" );
lcd->move( 0, 0 );
sBar = new QScrollBar( 0, 99, // range
1, 10, // line/page steps
0, // inital value
QScrollBar::Horizontal, // orientation
1, 10, // line/page steps
0, // inital value
QScrollBar::Horizontal, // orientation
this, "scrollbar" );
label = new QLabel( this, "label" );
label->setAlignment( AlignCenter );
......@@ -57,11 +57,11 @@ void LCDRange::setValue( int value )
void LCDRange::setRange( int minVal, int maxVal )
{
if ( minVal < 0 || maxVal > 99 || minVal > maxVal ) {
warning( "LCDRange::setRange(%d,%d)\n"
"\tRange must be 0..99\n"
"\tand minVal must not be greater than maxVal",
minVal, maxVal );
return;
warning( "LCDRange::setRange(%d,%d)\n"
"\tRange must be 0..99\n"
"\tand minVal must not be greater than maxVal",
minVal, maxVal );
return;
}
sBar->setRange( minVal, maxVal );
}
......
......@@ -21,22 +21,22 @@ LINK = link /DEBUG /SUBSYSTEM:windows /NODEFAULTLIB:libcd.lib
####### Files
HEADERS = cannon.h \
gamebrd.h \
lcdrange.h
gamebrd.h \
lcdrange.h
SOURCES = cannon.cpp \
gamebrd.cpp \
lcdrange.cpp \
main.cpp
gamebrd.cpp \
lcdrange.cpp \
main.cpp
OBJECTS = cannon.obj \
gamebrd.obj \
lcdrange.obj \
main.obj
gamebrd.obj \
lcdrange.obj \
main.obj
SRCMETA = moc_cannon.cpp \
moc_gamebrd.cpp \
moc_lcdrange.cpp
moc_gamebrd.cpp \
moc_lcdrange.cpp
OBJMETA = moc_cannon.obj \
moc_gamebrd.obj \
moc_lcdrange.obj
moc_gamebrd.obj \
moc_lcdrange.obj
TARGET = t14.exe
####### Implicit rules
......@@ -44,44 +44,44 @@ TARGET = t14.exe
.SUFFIXES: .cpp
.cpp.obj:
$(CC) -c $(CFLAGS) -I$(INCDIR) -Fo$@ $<
$(CC) -c $(CFLAGS) -I$(INCDIR) -Fo$@ $<
####### Build rules
all: $(TARGET)
$(TARGET): $(OBJECTS) $(OBJMETA) $(LIBDIR)\qt.lib
$(LINK) -OUT:$(TARGET) $(OBJECTS) $(OBJMETA) $(LFLAGS)
$(LINK) -OUT:$(TARGET) $(OBJECTS) $(OBJMETA) $(LFLAGS)
mocify: $(SRCMETA)
clean:
del $(OBJECTS) $(OBJMETA) $(SRCMETA)
del $(OBJECTS) $(OBJMETA) $(SRCMETA)
####### Compile
cannon.obj: cannon.cpp \
cannon.h
cannon.h
gamebrd.obj: gamebrd.cpp \
gamebrd.h \
lcdrange.h \
cannon.h
gamebrd.h \
lcdrange.h \
cannon.h
lcdrange.obj: lcdrange.cpp \
lcdrange.h
lcdrange.h
main.obj: main.cpp \
gamebrd.h \
lcdrange.h \
cannon.h
gamebrd.h \
lcdrange.h \
cannon.h
moc_cannon.cpp: cannon.h
$(MOC) cannon.h -o moc_cannon.cpp
$(MOC) cannon.h -o moc_cannon.cpp
moc_gamebrd.cpp: gamebrd.h
$(MOC) gamebrd.h -o moc_gamebrd.cpp
$(MOC) gamebrd.h -o moc_gamebrd.cpp
moc_lcdrange.cpp: lcdrange.h
$(MOC) lcdrange.h -o moc_lcdrange.cpp
$(MOC) lcdrange.h -o moc_lcdrange.cpp
TEMPLATE = qtapp
HEADERS = cannon.h \
gamebrd.h \
lcdrange.h
gamebrd.h \
lcdrange.h
SOURCES = cannon.cpp \
gamebrd.cpp \
lcdrange.cpp \
main.cpp
gamebrd.cpp \
lcdrange.cpp \
main.cpp
TARGET = t14
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment