Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Can Vector objects be instable?  (Read 710 times)
0 Members and 1 Guest are viewing this topic.
Offline gridur

Senior Newbie




Groovy


« Posted 2005-07-30 12:52:36 »

Hey!

I have a newbie q for ya'll =)

Im having some problems with a path route system that i have made for my editor, this system is used to make patrol routes for enemies in the game, to do this you have to get into the path route mode.
When youre here you click with left mb to add a path point and right mb to delete the last point in the route.

The thing now is that sometimes when i put a point ner another enemy, the active enemy just dissapears and the enemy thats closest to the new point gets to be the active enemy, this i think is pretty wierd and anoying.

So the question is: Can Vector objects be unstable and work in paculiar ways or is it my code that is funky?

here's some code:

Enemy path mode:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
         if(enemyPath)
         {
            if(me.getButton() == 1)
            {
               if(me.getX() > 40 && me.getX() < 140 && me.getY() > 30 && me.getY() < 50)
               {
                  enemyPath = false;
                  firstClick = false;
               }
               else if(me.getX() > 20 && me.getX() < 600 && me.getY() > 20 && me.getY() < 500 && firstClick)
               {
                  int i;
                  i = e.patrolCount;
                  if(i < 23)
                  {
                     e.patrolRoute[i][0] = (double)(me.getX()-indexX);
                     e.patrolRoute[i][1] = (double)(me.getY()-indexY);
                     e.patrolCount++;
                  }
               }
               else
                  firstClick = true;
            }
            else
            {
               if(e.patrolCount > 0)
                  e.patrolCount--;
            }
            m.e.set(activeEnemy, e);
         }


Activate Enemy Event:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
         else if(me.getButton() > 1 && !enemyPath && !enemyMode && !enemyPref)
         {
            if(me.getX() > 20 && me.getX() < 600 && me.getY() > 20 && me.getY() < 500)
            {
               int TileX = (int)(me.getX()-indexX);
               int TileY = (int)(me.getY()-indexY);
               
               for(int i = 0; i < m.e.size(); i++)
               {
                  e = m.e.get(i);
                 
                  if(TileX > e.pos[0] && TileX < e.pos[0] + 48 && TileY > e.pos[1] && TileY < e.pos[1] + 48)
                  {
                     activeEnemy = i;
                     enemyMode = true;
                  }
               }
            }
         }


Tnx

// Gridur<br />--------------------------------------<br />Spell of Play Studios<br />http://www.spellofplay.com<br /><br />Download and test the open Beta of Time Breaker (3D Arkanoid) and comment on our forum!<br />---------------------------------
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-08-02 01:12:34 »

Hmm.

Vector should be pretty hard to screw up as AIR its absoltuely, paranoidly, thread safe.
For that reason its often recommended you use the List objects instead and do your own
syncronization where it matters.  If you knwo what you are doing, this *can* give you better performance as you will only have threads blockign each other where it is really encessary.

But to answer your primnary question, no.  Given how thread safe Vectors are I cant imagine any way you could be making things just disappear from them.  Id suggest you check your other code.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline gridur

Senior Newbie




Groovy


« Reply #2 - Posted 2005-08-02 06:13:01 »

hehe ok, good to know, then i'll start deepsearching every line that has with the Vector objects to do, so that i can solve that problem.
I'll be taking a check at the list object solvation to, see if its something that fits better in the code design =)

Very well, thanx for the help!

// Gridur<br />--------------------------------------<br />Spell of Play Studios<br />http://www.spellofplay.com<br /><br />Download and test the open Beta of Time Breaker (3D Arkanoid) and comment on our forum!<br />---------------------------------
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (37 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (60 views)
2014-09-21 02:42:18

BurntPizza (30 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (52 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!