java – NPE when accessing an array with objects defined by the loop for

So I create a SnakeBird type game with a level editor, and when a new level is created, I wish it is only composed of free tiles. I've tried creating a 2D array and filling it with tiles, but that does not seem to work.

TileGrid.java

Public class TileGrid {
private tile[][]    map;
private int w, h;
private level l;

TileGrid public (int w, int h, level l) {
this.w = w;
this.h = h;
this.l = l;
this.map = new tile[this.w][this.h];

for (int i = 0; i <this.map.length; i ++) {
for (int j = 0; j <this.map[i].length; j ++) {
map[i][j]    = new tile (TileState.FREE, Tile.DEF_TILE_DIM * i, Tile.DEF_TILE_DIM * j, this.l);
}
}
}

tick public empty () {
for (int i = 0; i <map.length; i ++) {
for (int j = 0; j <map[i].length; j ++) {
Mosaic t = map[i][j];
t.tick ();
}
}
}

made public empty (Graphics g) {
for (int i = 0; i <map.length; i ++) {
for (int j = 0; j <map[i].length; j ++) {
Mosaic t = map[i][j];
tenderness (g);
}
}
}

public tile[][]    getMap () {
return the map;
}

}

Tile.java

public class Tile {
public static final int DEF_TILE_DIM = 25;
private int w = DEF_TD, h = DEF_TD, gridX, gridY;
private TileState status; // enum with different states
private level l;

public tile (TileState state, int x, int y, level l) {
this.state = state;
this.lx = x;
this.ly = y;
this.l = l;
}

tick public empty () {

}

made public empty (Graphics g) {
switch (state) {
FREE case:
TileRenderer.renderFREE (g, gridX, gridY, w, h);
Pause;
fruit case:
TileRenderer.renderFRUIT (g, gridX, gridY, w, h);
Pause;
PORTAIL case:
TileRenderer.renderPORTAL (g, gridX, gridY, w, h);
Pause;
SNAKE case:
TileRenderer.renderSNAKE (g, gridX, gridY, w, h);
Pause;
FIELD case:
TileRenderer.renderTERRAIN (g, gridX, gridY, w, h);
Pause;
default:
TileRenderer.renderFREE (g, gridX, gridY, w, h);
Pause;
}
}

public TileState getState () {
return condition;
}

}

Niveau.java

Public class Level {
final public final int DEF_LW = 32, DEF_LH = 18;
private int lw, lh;
private TileGrid grid;

public level (int lw) {
this.lw = lw;

if (lw == DEF_LW) {
this.lh = DEF_LH;
} other {
while (this.lw% 16! = 0) {
this.lw ++;
}

this.lh = this.lw / 16 * 9;
} // create a ratio of 16/9 tiles

grid = new TileGrid (this.lw, this.lh, this);
}

tick public empty () {
grid.tick ();
}

made public empty (Graphics g) {
grid.render (g);
}

}

When I try to access one of the tiles of TileGrid.map it throws a NullPointerException exception. It seems that the TileGrid builder for() the loop is not Actually put any tile, because I tried to access it separately in another class and she still does not recognize any of them. is there a problem with for() loops that I did not know or is it just a mistake?

javascript – how can I separate objects from an array?

Let's say your table is calling options, and you want to generate a second table with only the elements that have the property option equal to one, with the function filter of javascript (which you can use from the ECMAScript 5), you can do it:

var optionShoot = 1;
var SegmentOne = options.filter (function (element) {
return element.opcion == optionFind;
});

Another alternative is to browse your array of objects and save the items that interest you (in this case, for example, those with the option equal to one)

var segmentOne = [];
var optionShoot = 1;
opciones.forEach (element => {
if (element.opcion == optionSearch) {
SegmentOne.push (element);
}
});

terminology – What is the difference between OVAL definitions, objects and tests?

I'm trying to get to know OVAL better tST def and obj references in the joval xml definition files.

For example, I will see things like:


And then other areas will have things like:


and then other things like:


What is the difference between these three types of data? What is an object? What's a definition? What is a test?

3.5nd dnd – Are there updates to the DMG file describing the activation of a magic object in the format presented in the compendium of magic objects?

Direct explanatory question as described in the title. Magic Item Compendium presents the activation of magic objects in this way [Action Type] (type of action) according to page 220. Anyone is aware of a DMG update describing the magic objects presented there in the same format?

Take, for example, page 125 of the Magic Item Compendium, RING OF LIGHTNING FLASHES, which indicates that activation is performed. [Swift] (mental) that produces a comparable spell effect that causes direct damage. Whereas reading a Basic Control Ring (Fire) on page 231 DMG includes one of the following actions: Burning Hands, Flaming Sphere, Firewall, or Flame Attack requires standard action. This kind of disparity in the economy of action seems a little strange to me. Just to be clear, I understand that quick and immediate actions were introduced after the release of the DMG, hence the question.

5th dnd – What are the good rewards for players (other than XP and objects)?

In the DMG, p. 227-232, there is a section called Other Rewards, which lists items such as Blessings, Charms, and even Epic Boons (though it's at level 20 or higher).

In particular, Blessings (pp. 227-228) or perhaps Training (in particular, learning skills or prowess, p.231, although this implies that it should take some time, but you can give it up ) might be suitable for your "something that is not a" physical requirement ".

In terms of +1 to a capacity score, this is roughly half of an ASI, which the box on page 230 suggests as an alternative to Epic Boons. Given that Epic Boons is targeted at the 20+ level, this suggests that a full ASI is a big problem, but on the other hand, it also suggests that you can learn exploits during your downtime (p.231). , many of which include a +1, so I think +1 to a capacity score is not a big deal.

reactjs – Javascript Objects: Find the first nested object with null values

I have an API that returns a nested object of this form:

obj: {
nestedobj1: {
name: "a,"
prop2: & bg,
prop3: this is
prop4: & # 39; d & # 39;
}
nestedobj2: {
name: "a,"
prop2: & bg,
prop3: this is
prop4: & # 39; d & # 39;
}
nestedobj3: {
name: null,
prop2: null,
prop3: null,
prop4: null
}
nestedobj4: {
name: null,
prop2: null,
prop3: null,
prop4: null
}
// and so on up to 15 nested objects whose internal properties are null
}

These nested objects are assumed to contain a row of table data. When the user enters the details of the fields, the entries must be saved in one of the nested objects for which the value of the name is null. How to get there in javascript?

collision detection – Find the coordinates of objects colliding in Python

I have a group containing my extraterrestrials and another containing the bullets that I have shot. When I detect their collisions, I want to extract the x-y coordinates of the extraterrestrial during its deletion in order to be able to place an explosion animation at this location. How can I get there? My attempts up to now give an error saying that group items can not be indexed.

This is my first real coding project – so new again. I use Pygame to do the game.

Current collision detection code:

def check_bullet_alien_collisions (ai_settings, screen, stats, qn, boat, extraterrestrial, bullets, bombs):
"" "Respond to bullet-alien collisions" ""

collisions = pygame.sprite.groupcollide (chips, extraterrestrials, real, true)

The XCollect X-Y coordinates here

in case of collision:
for foreigners in collisions.values ​​():
stats.score + = ai_settings.alien_points * len (aliens)
sb.prep_score ()
stats.aliens_hit + = 1
stats.calc_accuracy ()
sb.accuracy ()
check_high_score (stats, sb)  

dnd 5th – What methods exist to damage or destroy worn objects?

We can start with the most available: attack it.

Monsters: the vase

Black Pudding (MM 241) and Gray Slime (MM 243) each have an ability to corrode armor and non-magical weapons. These abilities give a -1 penalty to the object at the time of the strike (whether by the vase or the wearer, as the case may be) and destroy them if the penalty is sufficient. The abilities vary. Black Puddings can corrode wooden or metal weapons and all non-magical armor, while Gray Oozes corrodes only metal weapons and armor.

Monsters: spectators

The Disintegration Ray of Beholders and Death Tyrants (and some of their loved ones) can target objects (no mention of being worn or worn) and destroys those who are not magical (Big or Small or 10 cubic feet of huge or larger). It's perhaps one of the least scary things that a spectator can do to you.

Spells: damage to objects

As established by this answer, a spell can cause damage to objects and does not state that the target must do not to be worn, can damage them. This includes the following:

  • Bigby's hand: 4d8 points of strength damage in melee attack, one target per turn.
  • Chain of Light: 10d8 lightning damage with dexterity backup. Up to 10 targets.
  • Water control: Do not mention that objects can not be worn or worn, it should probably.
  • Fire bolt: 1d10 fire damage (more at higher levels) during a ranged attack.
  • Melf's acidic arrow: 6d4 acid damage on the ranged spell attack.
  • Sword of Mordekainen: 3d10 Force damage in melee spell attacks on each turn.
  • Burning ray: Total 6d6 fire damage during ranged attacks.
  • Storm of revenge: 1d6 acid, 10d6 lightning, there are many things in this spell, it's a level 9 spell.

To spell: Disintegrate

Disintegrate likewise can target an object and will destroy non-magical objects that are large or smaller. Alternatively, you can target the creature that carries the item (s) and destroy it as well as all the things it carries:

[…] Yes [the spells] damage reduces the target to 0 health, it is disintegrated.

A disintegrated creature and everything it wears and carries, except magic items, is reduced to a pile of fine gray dust.

Player's manualp. 233

To spell: make

This may require a favorable decision from your DM, but this 4th level spell allows you to turn objects into other objects, with no obligation to wear them or not. However, the target item (s) must be considered as a "raw material" and the casting time of the spell is 10 minutes, so your use cases may be limited.

To spell: Wish

Wish can do anything you can convince and state for your DM to let it do. This will include interaction with the worn / worn objects. I hope the interaction is worth it for a level 9 spell and withstand the stress of the free form wish. I mention wish not because it's interesting, but it's what happened.


Honorable mention: Telekinesis

This spell does not damage or destroy the objects themselves, but it can be used for this purpose. The relevant section of the description of the spell:

You can try to move an object weighing up to 1000 pounds. If the item is not worn or worn, you move it automatically up to 30 feet in any direction, but not beyond the scope of that spell.

If the item is worn or carried by a creature, you must perform a ability check with your casting ability countered by the creature's power control. If you succeed, you spread the creature's object and can move it in any direction, but not beyond the scope of that spell.

Player's manualp. 280-281

the mage's hand cantrip may also be able to accomplish this, but has no explicit rules allowing it.

You can use the hand to manipulate an object […]

Player's manualp. 256

Although they do not damage or destroy the object itself, you may be able to use mage's hand or telekinesis make sure the object is no longer worn or worn, and can be damaged by other spells such as to break or fireball.

2d – Unity Colliders – How to detect nearby objects without my detection ranges detecting each other

How to get the types of both colliders in a trigger overlap message like OnTriggerExit2D (Collider2D other)?

Example:

  • objects A and B both have a BoxCollider2D and CircleCollider2D Components.

  • Then, object A enters one of the trigger colliders of object B.

  • I can get object BThe type of collider with the is operator.

How can I get the type of collider from A?

The reason I want this is that I only want collisions where object Aof CircleCollider2D touch object Bof BoxCollider2D.

void OnTriggerExit2D (Collider2D other)
{
if (other is BoxCollider2D)
// Do Code
}

Here's a chart of what I want: I just want to record overlaps of triggers from CircleCollider2D at BoxCollider2D. With the is operator, I can safely remove all collisions CircleCollider2D but collisions between two BoxCollider2D rest, what I do not want.

+ ------------------ + --------------- + -------------- ---- +
| Column row | BoxCollider2D | CircleCollider2D |
+ ------------------ + --------------- + -------------- ---- +
| BoxCollider2D | No | No |
| CircleCollider2D | Yes | No |
+ ------------------ + --------------- + -------------- ---- +

edit
The real question was to detect nearby objects without detecting the detection range.

finder – Automator: how to erase the "obtained" objects?

I've created an Automator workflow that (should) create a copy of a particular file in the currently selected folder. (ie select a folder, perform the quick action, get a copy of the file in the folder.

However, when I perform the fast action, I get the file and two copies of the folder itself, in itself. These are not links (I think), but I get some iterations.

Here is the workflow:
enter the description of the image here

I think the "Path" variable is copying for some reason. Maybe because it was "Got". Is there a way to clear the "get"?

Even if I delete the action "Get selected items from the Finder", I always get a copy of the folder.