2nd – The PyBox2D car moves uncontrollably

I'm trying to program TopDown Car using python and Box2D (similar to this tutorial: http://www.iforce2d.net/b2dtut/top-down-car) The direction is so far limited to three states wheel rotation, which I will have to solve later, now
I have trouble controlling the speed of the car.

import pygame
since import pygame.locals KEYDOWN, K_SPACE, K_w, K_s, K_a, K_d, K_ESCAPE, K_SPACE, QUIT, K_LEFT, K_RIGHT
import numpy as np


import Box2D # The main library
# Box2D.b2 maps Box2D.b2Vec2 to vec2 (and so on)
from the Box2D.b2 import (world, polygonShape, staticBody, dynamicBody, circleShape)
from the Box2D import (b2FixtureDef, b2PolygonShape, b2Vec2)

PPM = 15
TARGET_FPS = 60
TIME_STEP = 1.0 / TARGET_FPS
SCREEN_WIDTH, SCREEN_HEIGHT = 640, 480

screen = pygame.display.set_mode ((SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32)
pygame.display.set_caption ('Car up and down')
clock = pygame.time.Clock ()

# Creates the world
GRAVITY = [0, 0]
world = world (gravity = (GRAVITY), doSleep = True)

Top_Down_BodyWork_Shape = [(11.5, 0.0),
            (13.0, 2.5),
            (12.25, 5.5),
            (11, 7.5),
            (10.25, 10.0),
            (9.75, 10.0),
            (9, 7.5),
            (7.75, 5.5),
            (7.0, 2.5),
            (8.5, 0.0),
            ] # 1 axis of symmetry

Tire_Anchoring = [(7.0, 0.75),
            (13.0, 0.75),
            (7.0, 8.50),
            (13.0, 8.50),
            ]

### DEFINITION OF THE CAR TOP DOWN DOWN ###

Wheels = []
Suspensions = []

Top_Down_BodyWork = world.CreateDynamicBody (position = (0, 0),
angle = 0,
fixtures = b2FixtureDef (
shape = b2PolygonShape (vertices = Top_Down_BodyWork_Shape),
density = 2,
friction = 0.3))

for i in the beach (4):
# Create wheels
Wheels.append (world.CreateDynamicBody (position = (Tire_Anchoring)[i])
angle = 0,
fixtures = b2FixtureDef (
form = b2PolygonShape (case = (0.5, 1.5)),
density = 1.0,
friction = 1)))

# Anchor wheels to the body

if I am within range (2):
# The rear wheels do not move and can be welded to the body
Suspensions.append (world.CreateWeldJoint (bodyA = Top_Down_BodyWork,
bodyB = Wheels[i],
localAnchorA = Tire_Anchoring[i],
localAnchorB = (0,0),
))
other:
# The front wheels are rotary joints
Suspensions.append (world.CreateRevoluteJoint (bodyA = Top_Down_BodyWork,
bodyB = Wheels[i],
localAnchorA = Tire_Anchoring[i],
localAnchorB = (0,0),
enableMotor = True,
maxMotorTorque = 100000,
enableLimit = True,
lowerAngle = -np.pi / 4,
upperAngle = np.pi / 4,
motor speed = 0,
))

Left_Wheel, Right_Wheel = Wheels[2]Wheels[3]
Left_Susp, Right_Susp = Suspensions[2], Suspensions[3]

### DRAWING ###

colors = {dynamicBody: (133, 187, 101, 0), staticBody: (15, 0, 89, 0)}


def my_draw_polygon (polygon, body, fixture):
vertices = [(body.transform * v) * PPM for v in polygon.vertices]
vertices = [(v[0], SCREEN_HEIGHT - v[1]) for v in the vertices]pygame.draw.polygon (screen, colors[body.type], vertices)
polygonShape.draw = my_draw_polygon


def my_draw_circle (circle, body, fixture):
position = body.transform * circle.pos * PPM
position = (position[0], SCREEN_HEIGHT - position[1])
pygame.draw.circle (screen, colors[body.type], [int(
    x) for x in position], int (circle.radius * PPM))
circleShape.draw = my_draw_circle

### MAIN GAME LOOP ###

SteerAngle = 0
Speed ​​= 0
dV = 0.01 # Increment of speed

running = True
number_of_states = 0
max_lateral_impulse = 30
Right_Normal_Squared = []
tick_counter = 0

while running:
# Check the queue of events
for the event in pygame.event.get ():
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
# The user has closed the window or pressed the escape key
running = False

screen.fill ((255, 255, 255,0))
for body in world.bodies:
for fixture in body.fixtures:
fixture.shape.draw (body, fixture)

# Cancellation of lateral speed
for wheel in wheels:

if wheel in the range (2):
Carry on
other:


Current_Normal = wheel.GetWorldVector ((0,1))
Current_N_Squared = Current_Normal.dot (wheel.linearVelocity) * Current_Normal

Right_Normal = wheel.GetWorldVector ((1,0))
Right_Normal_Squared = Right_Normal.dot (wheel.linearVelocity) * Right_Normal

Impulse = -Right_Normal_Squared * wheel.mass
if Impulse.length> max_lateral_impulse:
Impulse * = max_lateral_impulse / Impulse.length

wheel.ApplyLinearImpulse (Impulse, wheel.worldCenter, True)
# Allow skidding
aimp = 0.25 * wheel.inertia * -wheel.angularVelocity
wheel.ApplyAngularImpulse (aimp, True)

current_forward_speed = Current_N_Squared.Normalize ()

drag_force_magnitude = -2 * current_forward_speed
wheel.ApplyForce (drag_force_magnitude * Current_N_Squared,
wheel.worldCenter, True)

# Command up and down the car (WASD keys)

if event.type == KEYDOWN and event.key == K_w:

Left_Wheel.ApplyLinearImpulse (b2Vec2 (10,0), Left_Wheel.position, False)
Right_Wheel.ApplyLinearImpulse (b2Vec2 (10,0), Left_Wheel.position, False)

elif event.type == KEYDOWN and event.key == K_s:
Left_Wheel.ApplyLinearImpulse (b2Vec2 (-10,0), Left_Wheel.position, True)
Right_Wheel.ApplyLinearImpulse (b2Vec2 (-10,0), Left_Wheel.position, True)


if event.type == KEYDOWN and event.key == K_a:
Left_Susp.motorSpeed ​​= 1.5
Right_Susp.motorSpeed ​​= 1.5

elif event.type == KEYDOWN and event.key == K_d:
Left_Susp.motorSpeed ​​= -1.5
Right_Susp.motorSpeed ​​= -1.5

world.Step (TIME_STEP, 10, 10)
tick_counter + = 1

if tick_counter> TARGET_FPS:
Left_Susp.motorSpeed ​​= 0.
Right_Susp.motorSpeed ​​= 0.
tick_counter = 0

pygame.display.flip ()
clock.tick (TARGET_FPS)

pygame.quit ()
print ('done!')

The problem is that the vehicle moves quite uncontrollably, I press "W" to move forward, "A" or "D" to steer, but I often need to press the "S" key to keep moving forward (which is of course counterintuitive) and when I press "W", it does not move continuously, a pulse is added and the car stops sooner or later.

I know that to move more realistically, I have to play with the aimp or max_lateral_velocity values, but how can I get continuous movement and better control of the car?

Thank you very much, any help appreciated.

When you delete a label via Google Contact Api v3, it removes the label, but moves all contacts to other contacts.

When you delete a label via Google Contact Api v3, the label is deleted, but all contacts are moved to other contacts. I want to delete the label and all his contacts. The URI invoked is the one provided by Google Docs, located under the label. It's ruby

request = @ client.generate_request (

: uri => "https://www.google.com/m8/feeds/groups/email/full/groupid",

: http_method => "DELETE",

: parameters => {

: v => 3.0 & # 39;

: xoauth_requestor_id => & # 39; me & # 39;
}

: headers => {
& # 39; If-Match & # 39; => & # 39;
)

answer = execute! (request)

moves the postgresql 9.4 database cluster to debian buster

I have a postgresql file backup (no dump) from postgresql 9.4.

On my Debian Buster server, I want to run this old database. So I reinstalled postgresql-9.4 with this tutorial: https://wiki.postgresql.org/wiki/Apt#Quickstart

Now he knows

pg_createcluster 9.4 main --start
Configuration of an existing cluster (configuration: /etc/postgresql/9.4/main, data: /var/lib/postgresql/9.4/main, owner: 117: 120)
Error: move_conffile: The required configuration file /var/lib/postgresql/9.4/main/postgresql.conf does not exist.

I managed to start a new cluster2: https://stackoverflow.com/a/48624460/1069083

But this one is empty. My old main cluster contains all my data.

How to start the old main cluster?

2010 – SharePoint C # moves the attachment and keeps the creative values ​​in SP 2019

We want to copy attachments from one element of a site collection to another element of another, with the help of C # (template). server-side object).

Is it possible to keep or replicate the fields Creation Variables: Author and Creation Time?

SPFile.TimeCreated
SPFile.Auteur

Thank you

Nikon D3300 shutter error but the shutter moves freely

My D3300 displays "Shutter Error" and will not record any photos, nor any live stream. When I have it in manual mode, I can see the shutter flipping easily and everything seems to be in place and working mechanically. Sometimes he will take a picture but it is only a dark purple image (picture below). I know it's a problem between $ 300 and $ 400 at my local photographer and I do not want to pay that, it's more than the camera. Could it be that the shutter is moving too slowly? No advice? enter the description of the image hereenter the description of the image here

jpanel – JFrame image moves although it is set to 0.0

I use JFrame to display images. I just started, and at this point I wish that a character goes on screen. I have 2 files, one that extends JFrame (displays images) and a runner file. An image is a still background while the other is a moving character. However, it seems that both images seem to move and the position of the background is fixed.

I just started using JFrame and I do not know at all.

This is the file that extends JPanel:


public class testScene extends JPanel {

private int x = 60;
private int y = 60;
private Boolean end = false;

publicConvent PaintComponent (Graphics g) {
super.paintComponent (g);
ImageIcon background = new ImageIcon ("images \ map \ TestMap1.png");
i.paintIcon (this, g, 0, 0);

ImageIcon protag = new ImageIcon ("images \ protag \ protag_f.png");
j.paintIcon (this, g, x, y);
}

public int getX () {return x;}
public int getY () {return y;}
public boolean getEnd () {return end;}

public empty setX (int i) {x = i;}
public void setY (int i) {y = i;}
public void setEnd (boolean) {end = b;}

}

This is the expected runner:


Public class testSceneRunner {
public static void main (String[] args) {

                scene testScene = new testScene ();
scene.setBackground (Color.black);

JFrame jf = new JFrame ();
InListner keyIn = new InListner ();

jf.addKeyListener (keyIn);
jf.setTitle ("Test Scene");

jf.setSize (1020,600);
jf.setVisible (true);
jf.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
jf.add (scene);

while (! scene.getEnd ()) {
// simply change x or y according to keyboard input
try {
Thread.sleep (25);
} catch (InterruptedException e) {
e.printStackTrace ();
}
if (keyIn.getPressed () == 87) {
scene.setY (scene.getY () - 1);
}
if (keyIn.getPressed () == 65) {
scene.setX (scene.getX () - 1);
}
if (keyIn.getPressed () == 83) {
scene.setY (scene.getY () + 1);
}
if (keyIn.getPressed () == 68) {
scene.setX (scene.getX () + 1);
}
if (keyIn.getPressed () == 69) {
scene.setEnd (true);
}
jf.repaint ();
}
jf.dispatchEvent (new WindowEvent (jf, WindowEvent.WINDOW_CLOSING));
}

}

I want the background to stay still and the character moves when you press one of the WASD keys However, the background also moves.

dnd 5th – Initiative: Do I lose my attack / action if my target moves or dies before my combat turn?

Chapter 9 of the Basic Rules / PHB describes the operation of actions in combat.

The "Combat step by step" sidebar in the "Combat order" section lists the combat progress:

  1. Determine the surprise. The DM determines if a person involved in the fight is surprised.
  2. Establish positions. The DM decides where all the characters and monsters are. Given the order of the adventurers or their declared positions in the room or elsewhere, the DM determines where the opponents are – how far and in what direction.
  3. Roll the initiative. All those involved in the combat encounter initiative determine the order of the fighters' turns.
  4. In turn. Each participant in the battle takes his turn in the order of initiative.
  5. Start the next round. When everyone involved in the fight has had their turn, the turn ends. Repeat step 4 until the end of the fights.

As you can see, in this macro view, there is no indication that you are declaring your actions before taking your turn.

Looking at the "Your turn" section, we can see the kinds of things you can do in your turn:

In turn, you can move a distance up to your speed and take an action. You decide to act first or act first. Your speed – sometimes called your walking speed – is indicated on your character sheet.

The most common actions you can take are described in the Actions in Fight section. Many class features and other capabilities provide additional options for your action.

The Movement and Position section gives the rules of your movement.

You can not move, take action, or do anything during your turn. If you can not decide what to do in your turn, consider the Dodge or Ready action, as described in the "Actions in Action" section.

The section then describes the bonus actions:

Various class features, spells and other abilities allow you to perform an additional action on your turn, called bonus action. […] You can only perform a bonus action when a special ability, spell, or other feature of the game indicates that you can do something like bonus action. Otherwise, you do not have any bonus action to take.

And other activity in your turn:

You can communicate as you can, with brief words and gestures, in turn.

You can also interact for free with an object or feature of the environment, whether for your move or your action. For example, you can open a door while you are moving towards an enemy or draw your weapon as part of the same action you are using to attack.

If you want to interact with a second object, you must use your action. Some magic items and other special items always require action, as indicated in their descriptions.

And even reactions:

Some special abilities, spells and situations allow you to take a special action called reaction. A reaction is an instant response to any trigger, which can happen in your turn or at someone else 's. The opportunity attack, described later in this section, is the most common type of reaction.

… But as you can see, none of these rules states that you must declare the action you intend to take at any time. it is only said that you take them (some at any time, others when a certain condition is met or when a trait / spell allows you to take them).

Later in the section "Movement and Position" you will learn how the movement works:

In turn, you can advance to your speed. You can use as much or as little of your speed as you like, following the rules here.

[…]

You can interrupt your movement by using part of your speed before and after your action. For example, if you have a speed of 30 feet, you can move 10 feet, move to action, and then move 20 feet.

You can even move between attacks:

If you perform an action that includes multiple attacks with a weapon, you can further divide your movement by going from one attack to the other. For example, a fighter who can perform two attacks with the Extra Attack feature and has a speed of 25 feet can move 10 feet, make an attack, move 15 feet, and then attack again.

Again, there is no question of declaring your actions.

As you can see, nothing in the rules requires you to declare your shares in advance: you simply do what you want to do in your turn, if you have the movement, action, or bonus (or any other resource needed). ) available to do it.


Rules designer Jeremy Crawford unofficially confirms this fact on Twitter:

The D & D fight is sequential, with no action-statement phase at the beginning. Your turn can also be interrupted by someone's reaction. Such an interruption could, among other things, make you unable to function, which means that your intention to take certain steps has never occurred.

He adds, in response to a question about the combat order:

There are, indeed, tons of flexibility in the way things can be ordered in combat. But if one thing is conditional on another, it must be in order, because intention has no weight in the rules of combat, because you could be interrupted at any time and incapacitated.

He repeats it here:

The D & D fight has no phase of action-statement. Things happen in order, and you can be interrupted at any time by a reaction, a trap, etc. You can say, "I plan to move to the attack action," but that has no relevance in terms of rules until you do the action.

And again, in response to a question about the Monk's Flurry of Blows:

In D & D, the way you act in combat is to really act. There is no phase of declaration of action. The burst of blows occurs after the action of attack, which refers to the action itself and not a statement indicating that you will perform the action.

The product's edit page moves the tabs to the sidebar

In the default presentation of the admin product release page, we have an accordion style configuration. It's really annoying because you have to scroll through multiple pages each time you want to edit an option that is not part of the General tab. I would like to have a sidebar like on the client's editing page. Going to "admin-2columns-left" does not seem to do the trick. Is there a recommended way to do this?

How to make a character who moves like a slinky?

I have a school duty to do a 2D platform game, with a character who moves like crazy:

Example of slinky movement

(Animated example of the mission linked above)

  1. At first, the character must grow with time

  2. When the player presses a button, the character begins to bend to the next platform

  3. Its height when you press the button determines whether it will reach the next platform.

  4. After that, he has to shrink to his original size, and he starts again.

How can I approach this?

My Macbook Slider 2011 moves and clicks but does not work

My MacBook cursor moves well, clicks the touchpad, but clicks nothing. I've tried to right click and it works on some windows but not all. I tried to turn it off, it does not work. I've tried putting the machine to sleep, it does not work. Please help.