[QUOTE=meek;46210629]I need to make some sort of pong game
I am trying to get the movement for the little paddles right before I move onto collision. I am new to this and having trouble with keeping the paddles inside the canvas.
This is my handler function for controlling movement:
[code]
def keydown(key):
global paddle1_vel, paddle2_vel
speed = 4
if key == simplegui.KEY_MAP["w"]:
paddle1_vel = -speed
elif key == simplegui.KEY_MAP["s"]:
paddle1_vel = speed
[/code]
and here's the bit of code that updates the position of the paddle and checks that it's not going outside the canvas
[code]
if paddle1_pos >= (HEIGHT-1) - HALF_PAD_HEIGHT:
paddle1_vel = 0
paddle1_pos += paddle1_vel
[/code]
I am basically just setting the speed to 0 if it comes near the edges, which makes it so it won't move in the other direction either. I need to ignore commands to move down if it's at the edge of the canvas, but how do I do that?
[editline]12th October 2014[/editline]
I'm at pretty much the same point where I know the syntax but not how to make an actual game out of it, I googled for a module that allows you to create a simple GUI and read about how to create stuff like buttons, moving objects, etc in it. Maybe search for a module that has the stuff you need and learn it to start off.[/QUOTE]
Then do
[code]
if paddle1_pos >= (HEIGHT-1) - HALF_PAD_HEIGHT && paddle1_vel > 0:
paddle1_vel = 0
[/code]
I don't know what language you work in, but, basically do this:
[code]
if (position smaller than 0 and velocity is smaller then 0)
velocity = 0
else if (position greater than screen height and velocity is greater than 0)
velocity = 0
position += velocity
[/code]
Does anyone here know PowerShell?
[QUOTE=Cyberuben;46210866]Then do
[code]
if paddle1_pos >= (HEIGHT-1) - HALF_PAD_HEIGHT && paddle1_vel > 0:
paddle1_vel = 0
[/code]
I don't know what language you work in, but, basically do this:
[code]
if (position smaller than 0 and velocity is smaller then 0)
velocity = 0
else if (position greater than screen height and velocity is greater than 0)
velocity = 0
position += velocity
[/code][/QUOTE]
Ohh I see. Thank you!
[QUOTE=xxncxx;46210875]Does anyone here know PowerShell?[/QUOTE]
I use it on a daily basis, but more so using it in the PSE running generally basic commands, have debugged some scripts for work, but haven't done much of the writing my self. I understand it for the most part.
[QUOTE=TH3_L33T;46211470]I use it on a daily basis, but more so using it in the PSE running generally basic commands, have debugged some scripts for work, but haven't done much of the writing my self. I understand it for the most part.[/QUOTE]
I'm basically tasked with writing a PS script that finds all of the names of the current accounts on the system and sets them a specific password. I just need help figuring out how I would go about setting the password to all of the users in one script rather than having to rerun it for every different user.
WMI can be pretty powerful to obtain information about the system. Could use that to get all accounts, and then use that to change their passwords.
[code]Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2"[/code]
You can get all user accounts on the system. [URL="http://msdn.microsoft.com/en-us/library/aa394507%28v=vs.85%29.aspx"]Win32_UserAccount[/URL].
[URL="http://technet.microsoft.com/en-us/library/ee617261.aspx"]Set-ADAccountPassowrd[/URL] seem to be something you might be looking for.
[code]
# import the AD module
if (-not (Get-Module ActiveDirectory)){
Import-Module ActiveDirectory -ErrorAction Stop
}
# set new default password
$password = ConvertTo-SecureString -AsPlainText "Password01" -Force
# get list of account names (1 per line)
$list = Get-Content -Path c:\scripts\users.txt
# loop through the list
ForEach ($u in $list) {
if ( -not (Get-ADUser -LDAPFilter "(sAMAccountName=$u)")) {
Write-Host "Can't find $u"
}
else {
$user = Get-ADUser -Identity $u
$user | Set-ADAccountPassword -NewPassword $password -Reset
$user | Set-AdUser -ChangePasswordAtLogon $true
Write-Host "changed password for $u"
}
}
[/code]
Found that already out there, before I write anything I usually do some research and usually able to find something that gets me in the right direction. For the script above, you wouldn't import from a text file (unles you wanted to of course), you could just make it do it for all in the WMI list or what ever.
[QUOTE=TH3_L33T;46211569]WMI can be pretty powerful to obtain information about the system. Could use that to get all accounts, and then use that to change their passwords.
[code]Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2"[/code]
You can get all user accounts on the system. [URL="http://msdn.microsoft.com/en-us/library/aa394507%28v=vs.85%29.aspx"]Win32_UserAccount[/URL].
[URL="http://technet.microsoft.com/en-us/library/ee617261.aspx"]Set-ADAccountPassowrd[/URL] seem to be something you might be looking for.
[code]
# import the AD module
if (-not (Get-Module ActiveDirectory)){
Import-Module ActiveDirectory -ErrorAction Stop
}
# set new default password
$password = ConvertTo-SecureString -AsPlainText "Password01" -Force
# get list of account names (1 per line)
$list = Get-Content -Path c:\scripts\users.txt
# loop through the list
ForEach ($u in $list) {
if ( -not (Get-ADUser -LDAPFilter "(sAMAccountName=$u)")) {
Write-Host "Can't find $u"
}
else {
$user = Get-ADUser -Identity $u
$user | Set-ADAccountPassword -NewPassword $password -Reset
$user | Set-AdUser -ChangePasswordAtLogon $true
Write-Host "changed password for $u"
}
}
[/code]
Found that already out there, before I write anything I usually do some research and usually able to find something that gets me in the right direction. For the script above, you wouldn't import from a list, you could just make it do it for all in the WMI list or what ever.[/QUOTE]
I won't be using AD to do this so I'm gonna see if I can modify that script there to do it via WMI. Thanks a bunch!
I've made a small ST3 plugin to compile the current viewed file. Is there a way I can get the console output to print it into the ST3 console?
Does anyone know how to integrate fractions into Java? Have to make a calculator for APCS, and here is what I have so far:
[url]http://pastebin.com/FJU8zj65[/url]
Does anyone happen to know how the server query for ArmA III works?
I can get the server name, current and max players with a steam query, but it does not return the correct password state. (Always \x00 even if the server had a password)
Are there good pay prospects for Bioinformatics?
Is there an environmental variable in Ubuntu that will allow me to display the day of the week? (monday, tues, weds, etc.)
[editline]13th October 2014[/editline]
edit:
nevermind. $(date +%A) worked for me
I just finished a CS assignment but I am confused by his last line of requirements.
"Avoid all magic numbers in your code through judicious use of constants."
What is a magic number?
*edit* Nevermind I should have just googled it first.
A plain number with nothing indicating its purpose.
Like, if you compare something to, say, 0x7F and there's a perfectly fine reason to but it's just 0x7F written right in the code, nobody looking at it will know why it's that particular number.
So you should make it a constant with a descriptive name instead.
-FIXED-
-solved-
So I have these verlets, atoms, particles whatever you want to call them connected to each other to act like goo. I'll be drawing a solid polygon on top of these.
How do I go about calculating the direction I need to apply force to each verlet in order to rotate it clockwise and vise versa?
[t]http://puu.sh/cd0fp/1519c6887d.png[/t]
Upward force on left side for clockwise
Upward force on right side for counterclockwise
??
(Copied and pasted from my main thread, due to it not recieving much attention.)
------ Rebuild All started: Project: Helloworld, Configuration: Debug Win32 ------
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: The build stopped unexpectedly because of an internal failure.
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. MSBuild.exe could not be launched as a child node as it could not be found at the location "c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSB uild.exe". If necessary, specify the correct location in the BuildParameters, or with the MSBUILD_EXE_PATH environment variable.
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: at Microsoft.Build.BackEnd.NodeManager.AttemptCreateN ode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration)
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: at Microsoft.Build.BackEnd.NodeManager.CreateNode(Nod eConfiguration configuration, NodeAffinity nodeAffinity)
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: at Microsoft.Build.Execution.BuildManager.PerformSche dulingActions(IEnumerable`1 responses)
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: at Microsoft.Build.Execution.BuildManager.HandleNewRe quest(Int32 node, BuildRequestBlocker blocker)
c:\documents and settings\compaq_administrator.michael\my documents\visual studio 2010\Projects\Helloworld\Helloworld\Helloworld.vcx proj : error MSB4014: at Microsoft.Build.Execution.BuildManager.IssueReques tToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Essentially, I can't do anything in Microsoft Visual C++. My username is less than 16 chars, .net framework 4.0 is working fine. Help!
-snip- fixed rate dumb i'm a retard
um, why is my post dumb?
[QUOTE==(E)=AndromK;46253496]um, why is my post dumb?[/QUOTE]
[QUOTE]. Please make sure Msbuild.exe exist in C:\Windows\Microsoft.NET\Framework\v4.0.30128.
If it does not exist, please install .net framework 4.0, [url]http://www.microsoft.com/downlOAds/details.aspx?familyid=0A391ABD-25C1-4FC0-919F-B21F31AB88B7&displaylang=en[/url]
Thanks
Chao[/QUOTE]
Looks similar to your problem
[url]https://social.msdn.microsoft.com/Forums/vstudio/en-US/7b29020e-2aab-4648-840f-b18874c75397/problem-getting-c-projects-to-build[/url]
[QUOTE=reevezy67;46238009]So I have these verlets, atoms, particles whatever you want to call them connected to each other to act like goo. I'll be drawing a solid polygon on top of these.
How do I go about calculating the direction I need to apply force to each verlet in order to rotate it clockwise and vise versa?
[t]http://puu.sh/cd0fp/1519c6887d.png[/t][/QUOTE]
If you do something like
[code]
float movementSpeed = 5;
Vector3 desiredDirection = Vector3.right;
Vector3 directionFromCenter = center.position - atom.transform.position;
float forceFactor = Vector3.Dot(directionFromCenter, Vector3.Cross(Vector3.right,Vector3.forward)) * movementSpeed;//Get the amount of force required to spin atom at point, then scale according to speed
atom.rigidbody.AddForce(desiredDirection * forceFactor);
[/code]
This should give you the force vector for every atom, scaled properly so that no force is applied when it is inline with the direction vector, and that force is only applied at full at the top and bottom part.
Haven't tested if this works properly, but this'd be my first attempt
[editline]16th October 2014[/editline]
Maybe the arguments in the cross need to be reversed since I always forget what direction a vector is in after crossing two.
[editline]16th October 2014[/editline]
I just checked, this should work fine.
[unity]http://a.pomf.se/bfrhtt.unity3d[/unity]
control with left and right arrow keys.
[editline]17th October 2014[/editline]
I noticed it starts going faster because the distance from the center keeps getting bigger, if you normalize it, it gives you a maximum speed.
I tried making it work for all directions so you could go up slopes without it wasting energy, but it flips the sign on the dot product and cancelled out the direction change...
Maybe it looks similar because i copied and pasted it?
No one is helping me on my previous thread, so i posted it here.
[QUOTE==(E)=AndromK;46255751]Maybe it looks similar because i copied and pasted it?
No one is helping me on my previous thread, so i posted it here.[/QUOTE]
Did you try the solution I suggested?
[QUOTE=esalaka;46224858]A plain number with nothing indicating its purpose.
Like, if you compare something to, say, 0x7F and there's a perfectly fine reason to but it's just 0x7F written right in the code, nobody looking at it will know why it's that particular number.
So you should make it a constant with a descriptive name instead.[/QUOTE]
Alternatively I use named parameters where the language supports it, so that I don't have plain [I]true[/I] or [I]false[/I] in method calls for example.
[QUOTE=cody8295;46257393]Did you try the solution I suggested?[/QUOTE]
I did, but it didn't work.
Java Question
[code]
public class GravityV1
{
// calcGravity returns an array of doubles containing teh gravity values
//and takes two arrays of doubles as parameters for the radius values and mass
public static double[] calcGravity(double[] radius, double[] mass)
{
// fill in code here
// The formula to calculate gravity is:
// 6.67E-17 times the massOfPlanet divided by the radius of the planet squared
return ((6.67E-17) * mass[i])/(radii[i] * radii[i]);
}
// printResults will print the table to output screen
// return type is voide because no values are returned
public static void printResults(String[] name, double[] radius, double[] mass, double gravity[])
{
// fill in code here
}
//print the gravity values to text file
public static void printToFile(double[] gravity)throws IOException
{
// fill in code here
}
public static void main(String[] args)throws IOException
{
// Initialize variables
String[] names = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};
double[] radii = {2439.7, 6051.9, 6378, 3402.5, 71492, 60270, 25562, 24774, 1195};
//double[] masses = {3.3022 * Math.pow(10,23), 4.8685 * Math.pow(10,24), 5.9736 * Math.pow(10,24), 6.4185 * Math.pow(10,23), 1.8986 * Math.pow(10,27), 5.6846 * Math.pow(10,26), 8.6810 * Math.pow(10,25), 1.0243 * Math.pow(10,26), 1.312 * Math.pow(10,22)};
// or using big E notation:
double [] mass = {3.30E23, 4.87E24, 5.97E24, 6.42E23, 1.90E27, 5.68E26, 8.68E25, 1.02E26, 1.27E22}; // See IMACS double lesson for big E notation
for (int i = 0; i <= 9; i++)
{
mass[i];
radii[i];
double[] gravities = calcGravity(radii, mass);
i++
}
// Processing
double[] gravities = calcGravity(radii, mass);
// Output
printResults(names, radii, mass, gravities);
printToFile(gravities);
} //end main
}//end class[/code]
How the hell do I call an array in another method? I cannot for the life of me figure it out.
Edit:
Also how do I print array data into text files?
You either pass the array to the other method (as you're doing now), or you make that array a member variable. Judging by the complete lack of member variables in your code, your course probably hasn't introduced them yet, and you'll learn about them soon enough, so just use the first way.
Sorry, you need to Log In to post a reply to this thread.