To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1755
1754  |  1756
Subject: 
video game type thing...
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 12 Mar 2001 19:24:07 GMT
Viewed: 
1259 times
  
I'm building a video game type thing. It has three touch sensors, for left,
right, and fire. The LCD controls where the enemy is. I'm having some
problems with my code, so here it is(I'm using kernel 0.2.4):

#include "conio.h"
#include "dmotor.h"
#include "dsensor.h"
#include "unistd.h"
#define select TOUCH_2
#define right TOUCH_3
#define left TOUCH_1
int enemy;
int enemies;
int view;
int forward;
int backward;
int left;
int right;
int main(int argc, char **argv)
{
cputs("x");
enemy = 1;
if(TOUCH_2)
{
if(enemy = 1)
{
fight;
monitor;
}
}
}

void fight()
{
/*Put a beep here*/
if(enemy == 1)
{
cputs(" x ");
forward = 1;
right = 2;
backward = 3;
left = 4;
view = forward;
if(select == 1 && view = 1 && enemies != 0)
{
/*beep*/
sleep(1);
cputs("   ");
enemies = 0;
}
/*if I press the turn right button and I'm not looking left...*/
if(right = 1 && view < 4)
{
/*turn 90 degrees*/
view = view + 1;
}
/*if I press the turn right button and I AM looking left...*/
if(right = 1 && view == 4)
{
/*turn to the forward view(1)*/
view = 1;
}
/*now let's do the same for left*/
/*if I press the turn left button and I'm not looking right...*/
if(left = 1 && view > 2)
{
/*turn -90 degrees*/
view = view - 1;
}
/*if I press the turn left button and I AM looking right...*/
if(left = 1 && view == 2)
{
/*turn to the forward view(1)*/
view = 1;
}
}
}

void monitor()
{
while(1 == 1)
{
while(view == 1)
{
cputs(" x ");
}
}
while(enemies == 0)
{
while(1 == 1)
{
cputs("Exit");
msleep(500);
cls();
msleep(250);
cputs("Exit");
msleep(500);
cls();
msleep(250);
}
}
}
---------------------------------------------------------------------------
I'm having trouble with "return;", so I'm leaving some of the features out.
It's telling me that I'm not doing my voids correctly or calling my voids up
or something like that. Any help/comments?

Nick Howell



Message has 1 Reply:
  Re: video game type thing...
 
(...) I think you mean if (enemy == 1). Also, the identifier "fight" resolves to the address of the fight function. Doing "fight;" is equivalent to doing "1;". It's legal, but it doesn't accomplish anything. You want to do "fight();" and (...) (24 years ago, 12-Mar-01, to lugnet.robotics.rcx.legos)

13 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR