• What Do You Need Help With? V6
    7,544 replies, posted
Since the last one was closed along with a bunch of other threads, let's start over. Same procedure as last year, post all your questions that are not worthy of thread in here. [URL="http://www.facepunch.com/threads/910202"]What Do You Need Help With V1[/URL] [URL="http://www.facepunch.com/threads/1053117"]What Do You Need Help With V2[/URL] [URL="http://www.facepunch.com/threads/1092921"]What Do You Need Help With V3[/URL] [URL="http://www.facepunch.com/threads/1152030"]What Do You Need Help With V4[/URL] [URL="http://facepunch.com/showthread.php?t=1167392"]What Do You Need Help With V5[/URL]
[QUOTE=Gulen;39727389]Hopefully this is the right place to ask, I've just started learning C# (inspired by everyone in this sub-forum, thanks for that!), so far I've created a simple console naughts and crosses game, but I'm stumped on what to have a go at doing next, I was wondering if anyone could give me an idea or two to try?[/QUOTE] By the way, are you doing this at school or at home as a hobby?
I'm having some issues with some arduino code. It seems whenever I upload the following sketch, it will result in the serial port associated with the device disappearing when connected. This is a huge problem because I can't open the serial monitor to see what's happening in my code as it runs. [code] //Norseboard //Key (we need these for a keyboard apparently) //bouncekeys need to be dealt with later, but I'll see how things behave first struct Key{ //id can be expressed as a byte later, but for now I'll use a string for readability String id; boolean pressed; Key(String id) : id(id), pressed(false) {}; }; //Key state toggle void toggleKey(struct Key *key){ if(key->pressed) key->pressed = true; else key->pressed = false; }; boolean changed = false; const int COL_COUNT = 10; const int ROW_COUNT = 8; const uint8_t col[COL_COUNT] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; const uint8_t row[ROW_COUNT] = {A0, A1, A2, A4, 0, 1, 2, 3}; Key * const NOKEY = new Key("NONE"); Key * const BLUE = new Key("BLUE"); Key * const GREEN = new Key("GREEN"); Key * const YELLOW = new Key("YELLOW"); Key * const KEY_A = new Key("KEY_A"); Key * const KEY_B = new Key("KEY_B"); Key * const KEY_C = new Key("KEY_C"); Key * const KEY_D = new Key("KEY_D"); Key * const KEY_E = new Key("KEY_E"); Key * const KEY_F = new Key("KEY_F"); Key * const KEY_G = new Key("KEY_G"); Key * const KEY_H = new Key("KEY_H"); Key * const KEY_I = new Key("KEY_I"); Key * const KEY_J = new Key("KEY_J"); Key * const KEY_K = new Key("KEY_K"); Key * const KEY_L = new Key("KEY_L"); Key * const KEY_M = new Key("KEY_M"); Key * const KEY_N = new Key("KEY_N"); Key * const KEY_O = new Key("KEY_O"); Key * const KEY_P = new Key("KEY_P"); Key * const KEY_Q = new Key("KEY_Q"); Key * const KEY_R = new Key("KEY_R"); Key * const KEY_S = new Key("KEY_S"); Key * const KEY_T = new Key("KEY_T"); Key * const KEY_U = new Key("KEY_U"); Key * const KEY_V = new Key("KEY_V"); Key * const KEY_W = new Key("KEY_W"); Key * const KEY_X = new Key("KEY_X"); Key * const KEY_Y = new Key("KEY_Y"); Key * const KEY_Z = new Key("KEY_Z"); Key * const KEY_0 = new Key("KEY_0"); Key * const KEY_1 = new Key("KEY_1"); Key * const KEY_2 = new Key("KEY_2"); Key * const KEY_3 = new Key("KEY_3"); Key * const KEY_4 = new Key("KEY_4"); Key * const KEY_5 = new Key("KEY_5"); Key * const KEY_6 = new Key("KEY_6"); Key * const KEY_7 = new Key("KEY_7"); Key * const KEY_8 = new Key("KEY_8"); Key * const KEY_9 = new Key("KEY_9"); Key * const KEY_ENTER = new Key("KEY_ENTER"); Key * const KEY_ESC = new Key("KEY_ESC"); Key * const KEY_BACKSPACE = new Key("KEY_BACKSPACE"); Key * const KEY_TAB = new Key("KEY_TAB"); Key * const KEY_SPACE = new Key("KEY_SPACE"); Key * const KEY_MINUS = new Key("KEY_MINUS"); Key * const KEY_EQUAL = new Key("KEY_EQUAL"); Key * const KEY_LEFT_BRACE = new Key("KEY_LEFT_BRACE"); Key * const KEY_RIGHT_BRACE = new Key("KEY_RIGHT_BRACE"); Key * const KEY_BACKSLASH = new Key("KEY_BACKSLASH"); Key * const KEY_NUMBER = new Key("KEY_NUMBER"); Key * const KEY_SEMICOLON = new Key("KEY_SEMICOLON"); Key * const KEY_QUOTE = new Key("KEY_QUOTE"); Key * const KEY_TILDE = new Key("KEY_TILDE"); Key * const KEY_COMMA = new Key("KEY_COMMA"); Key * const KEY_PERIOD = new Key("KEY_PERIOD"); Key * const KEY_SLASH = new Key("KEY_SLASH"); Key * const KEY_CAPS_LOCK = new Key("KEY_CAPS_LOCK"); Key * const KEY_PRINTSCREEN = new Key("KEY_PRINTSCREEN"); Key * const KEY_SCROLL_LOCK = new Key("KEY_SCROLL_LOCK"); Key * const KEY_PAUSE = new Key("KEY_PAUSE"); Key * const KEY_INSERT = new Key("KEY_INSERT"); Key * const KEY_HOME = new Key("KEY_HOME"); Key * const KEY_PAGE_UP = new Key("KEY_PAGE_UP"); Key * const KEY_DELETE = new Key("KEY_DELETE"); Key * const KEY_END = new Key("KEY_END"); Key * const KEY_PAGE_DOWN = new Key("KEY_PAGE_DOWN"); Key * const KEY_RIGHT = new Key("KEY_RIGHT"); Key * const KEY_LEFT = new Key("KEY_LEFT"); Key * const KEY_DOWN = new Key("KEY_DOWN"); Key * const KEY_UP = new Key("KEY_UP"); Key * const KEY_NUM_LOCK = new Key("KEY_NUM_LOCK"); Key * const keyMatrix[COL_COUNT][ROW_COUNT] = { {GREEN, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {KEY_1, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I}, {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9}, {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {BLUE, YELLOW, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}, {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY} }; Key * keyPressed[6] = {NOKEY, NOKEY, NOKEY, NOKEY, NOKEY, NOKEY}; int keyPressedIndex = 0; static void resetKeys(){ for(int i=0; i<6; i++) keyPressed[i] = NOKEY; keyPressedIndex = 0; changed = false; } static void scanKeys(){ for(int currentCol = 0; currentCol < COL_COUNT; currentCol++){ digitalWrite(col[currentCol], HIGH); for(int currentRow = 0; currentRow < ROW_COUNT; currentRow++){ boolean state = digitalRead(row[currentRow]); Key* key = keyMatrix[currentCol][currentRow]; if((state == HIGH && !key->pressed) || (state == LOW && key->pressed)){ toggleKey(key); changed = true; } if(key->pressed){ if(keyPressedIndex<6){ keyPressed[keyPressedIndex] = key; keyPressedIndex++; } } } digitalWrite(col[currentCol], LOW); } } static void sendKeys(){ Serial.println("--Pressed Keys--"); for(int i=0; i<6; i++){ Serial.print("Key "); Serial.print(i+1); Serial.print(": "); Serial.println(keyPressed[i]->id); } Serial.println(""); } void setup(){ Serial.begin(9600); for(int i=0; i<COL_COUNT; i++) pinMode(col[i], OUTPUT); for(int i=0; i<ROW_COUNT; i++) pinMode(row[i], INPUT); } void loop(){ resetKeys(); scanKeys(); sendKeys(); delay(50); } [/code] I'm not very experience with arduino, so I'm not sure whether this is a common thing with bad code. If anyone has any ideas and can help, please chime in on this.
[QUOTE=eternalflamez;39747522]By the way, are you doing this at school or at home as a hobby?[/QUOTE] I bet he's doing it in his spare time, because of how he phrases his post, and that he's inspired by everyone in here.
When using Euler integration for physics, ie: [csharp] force += gravity; force /= mass; velocity += force * Globals.Delta; position += velocity * Globals.Delta; oldPosition = position; force.Set(0, 0); [/csharp] How do I add some loss so that objects dont move for ever?? I tried just multiplying the velosity by a loss, but then the object just keeps bouncing untill it just starts vibrating and going crazy
[csharp] ... force /= mass; velocity *= 0.8 * Globals.Delta; velocity += force * Globals.Delta; ... [/csharp] Is what I have always done.
I have a feeling I have done everything wrong :(, I tried that and now my ball goes really slow(which is normal) but its not responding to collision(probably is but when I do: [csharp]if(pO.Position.Y > 300){ pO.position = pO.oldPosition;; pO.DirectVelocity(90); //////////////////// // Direct the velocity in a certain direction, so that the object can hit angled surface // the angle parameter is the amount of degrees, straight right is 0 degrees, +degrees is counter clockwise public void DirectVelocity(float angle) { double currentAngle = velocity.Theta(); double differenceAngleInRadians = currentAngle - MathHelper.ToRadians(-angle);// converting -angle gives us the counter clockwise positive angles velocity.Rotate(differenceAngleInRadians); } /////////////////////////// } pO.Update(); ///////////////////////// force += gravity; force /= mass; velocity *= 0.8 * Globals.Delta; velocity += force * Globals.Delta; position += velocity * Globals.Delta * maxV; oldPosition = position; force.Set(0, 0); ///////////////////////// [/csharp]
You are reducing velocity before you add on the force
Yeah you likely want to apply the damping after updating the position. [csharp] force /= mass; velocity += force * Globals.Delta; position += velocity * Globals.Delta * maxV; velocity *= 0.8 * Globals.Delta; [/csharp]
You can just apply Dampening, or you can simulate Drag [img]http://upload.wikimedia.org/math/9/a/e/9aefe90983174c6ef1bc965d5ccb2de3.png[/img] Force(Drag in opposite direction) = .5 * Density(Air/Water) * Velocity(Object)^2 * Surface * Drag coefficient You don't have to exactly implement this, you can have drag as a static value, or even the Surface as a static value, But generally having some kind of dampening based on how fast you are going feels nice.
So I'm making this story generator and this is what I have so far [URL=http://minus.com/ltYBuoIbEBljm][IMG]http://i.minus.com/jtYBuoIbEBljm.png[/IMG][/URL] How do I add text on the top of the window bar (like where the tk is, I want to change the text and maybe add an icon of some sort) and how do I move the box below the Make Story! button? I'm also running into a problem where the story I generate doesn't show in the box. If I remove the box (or just not pack it), it would go right beside the Make Story! button. What I want it to do is to show up inside that text widget box every time, not as a live update but when the Make Story! button is pressed. In the code below I intentionally .pack() -ed the two outputs assuming that I needed them. Ignore any unused frames/pack. [code] import Tkinter class StoryMaker(): def __init__(self): ''' This initializes all of the required variables and frames and such ''' # making the main window happen self.main_window = Tkinter.Tk() # making them frames self.logo_frame = Tkinter.Frame(self.main_window) self.instructions_frame = Tkinter.Frame(self.main_window) self.character_frame = Tkinter.Frame(self.main_window) self.location_frame = Tkinter.Frame(self.main_window) self.occupation_frame = Tkinter.Frame(self.main_window) self.gender_frame = Tkinter.Frame(self.main_window) self.computer_frame = Tkinter.Frame(self.main_window) self.action_frame = Tkinter.Frame(self.main_window) self.story_frame = Tkinter.Frame(self.main_window) # packing them frames self.instructions_frame.pack(anchor = 'w') self.character_frame.pack(anchor = 'w') self.location_frame.pack(anchor = 'w') self.occupation_frame.pack(anchor = 'w') self.gender_frame.pack(anchor = 'w') self.computer_frame.pack(anchor = 'w') self.action_frame.pack(anchor = 'w') self.story_frame.pack(anchor = 'w') # making the Label text show up self.instructions = Tkinter.Label(self.instructions_frame, \ text = 'Enter some info to make your story!') self.character = Tkinter.Label(self.character_frame, \ text = 'Character Name') self.location = Tkinter.Label(self.location_frame, \ text = 'Current Location') self.occupation = Tkinter.Label(self.occupation_frame, \ text = 'Occupation') self.gender = Tkinter.Label(self.gender_frame, \ text = 'Gender') self.computer = Tkinter.Label(self.computer_frame, \ text = 'Computer') # packing them Label Text self.instructions.pack(side = 'left') self.character.pack(side = 'left') self.location.pack(side = 'left') self.occupation.pack(side = 'left') self.gender.pack(side = 'left') self.computer.pack(side = 'left') self.action_frame.pack(side = 'left') self.story_frame.pack(side = 'left') # making the text entry self.character_entry = Tkinter.Entry(self.character_frame, width = 20) self.location_entry = Tkinter.Entry(self.location_frame, width = 20) self.occupation_entry = Tkinter.Entry(self.occupation_frame, width = 20) # packing the text entry self.character_entry.pack(side = 'right') self.location_entry.pack(side = 'right') self.occupation_entry.pack(side = 'right') # making the radio buttons # Create an IntVar object to use with the Radiobuttons. self.radio_var = Tkinter.IntVar() # Set the intVar object to 1. self.radio_var.set(1) # Create the Radiobutton widgets in the top_frame. self.male_rb = Tkinter.Radiobutton(self.gender_frame, \ text='Male', variable=self.radio_var, \ value=1) self.female_rb = Tkinter.Radiobutton(self.gender_frame, \ text='Female', variable=self.radio_var, \ value=2) self.other_rb = Tkinter.Radiobutton(self.gender_frame, \ text='Other(s)', variable=self.radio_var, \ value=3) # Pack the Radiobuttons. self.male_rb.pack(side = 'left') self.female_rb.pack(side = 'left') self.other_rb.pack(side = 'left') # making the check boxes # Create three IntVar objects to use with the Checkbuttons. self.cb_var1 = Tkinter.IntVar() self.cb_var2 = Tkinter.IntVar() self.cb_var3 = Tkinter.IntVar() # Set the intVar objects to 0. self.cb_var1.set(0) self.cb_var2.set(0) self.cb_var3.set(0) # Create the Checkbutton widgets in the top_frame. self.cb1 = Tkinter.Checkbutton(self.computer_frame, \ text='PC', variable=self.cb_var1) self.cb2 = Tkinter.Checkbutton(self.computer_frame, \ text='Mac', variable=self.cb_var2) self.cb3 = Tkinter.Checkbutton(self.computer_frame, \ text='Other', variable=self.cb_var3) # Pack the Checkbuttons. self.cb1.pack(side = 'left') self.cb2.pack(side = 'left') self.cb3.pack(side = 'left') # Creating the Create Story button widget self.story_button = Tkinter.Button(self.story_frame, \ text='Make Story!', \ command = self.make_story) #packing the create story button self.story_button.pack(side = 'left') # We need a StringVar object to associate with # an output label. Use the object's set method # to store a string of blank characters. self.value = Tkinter.StringVar() # Create a label and associate it with the # StringVar object. Any value stored in the # StringVar object will automatically be displayed # in the label. self.story_output = Tkinter.Label(self.story_frame, \ textvariable=self.value) # trying to make Tkinter.Text self.text_widget = Tkinter.Text(self.story_output, width=25, height=10) self.text_widget.pack(side = 'bottom') self.story_output.pack(side = 'right') # the Tkinter main loop Tkinter.mainloop() def make_story(self): test = self.character_entry.get().strip() + " is a hard working person." self.value.set(test) story_maker = StoryMaker() [/code]
[QUOTE=eternalflamez;39747522]By the way, are you doing this at school or at home as a hobby?[/QUOTE] Just as a hobby, hoping it might help a little when I head off for Uni though
[QUOTE=Waerlock;39753831]Just as a hobby, hoping it might help a little when I head off for Uni though[/QUOTE] try [url]http://projecteuler.net/[/url] or maybe a 'roguelike' (just get your character moving through a 2D array)
I'm bored as shit and I want to expand my programming knowledge. All I know currently is javascript, and I really want to learn something actually useful. What do. [editline]1st March 2013[/editline] oh and a basic understanding of lua
[QUOTE=garychencool;39752762]So I'm making this story generator and this is what I have so far [/IMG] How do I add text on the top of the window bar (like where the tk is, I want to change the text and maybe add an icon of some sort) and how do I move the box below the Make Story! button? I'm also running into a problem where the story I generate doesn't show in the box. If I remove the box (or just not pack it), it would go right beside the Make Story! button. What I want it to do is to show up inside that text widget box every time, not as a live update but when the Make Story! button is pressed. In the code below I intentionally .pack() -ed the two outputs assuming that I needed them. Ignore any unused frames/pack. [/code][/QUOTE] Setting the title can be achieved by calling the Title() function of your window object. (self.main_window?) Can't really help you with the other parts, I barely know Python.
Is there a way to make Visual Studio 2012 not put { on a new line? I want it to be like [CODE]int main(){ doStuff(); }[/CODE] and not like [CODE]int main() { doStuff(); }[/CODE] I know there's an option for C#, but I can't find it for C++?
I am doing a program that find the longest symmetrical word in a sentence. But it somehow doesn't check the whole sentence. Am I doing it Right ? For example: If i enter "words" like aba, abba. They are both symmetrical. But the program only sees the first words as the longest , not the second Some code: [CODE] length = static_cast<int>(strlen(s)); for(i=0 ; i<length ; i++) { int j,k,n; for (n=0; n<2; n++) { j = i-n; k = i+1; subleng = n; while ( j>=0 && k<length && s[j]==s[k]) { subleng +=2; j--; k++; } if( subleng > maxi) { first= j + 1; maxi= subleng; } } } cout<<"The longest symmetric word is : \n"; for (i=0 ; i<maxi ; i++) { cout<<s[first+i]; }[/CODE]
so I'll restate my question for the new thread, however unfortunately timed my post was what kind of information is standard for sending per packet in a networked game? position and velocity, along with any important tidbits (direction, whatever)? and would this be sent over a single packet for each update, or would you split it so maybe absolute position updates come less frequently?
[QUOTE=Em See;39759187]so I'll restate my question for the new thread, however unfortunately timed my post was what kind of information is standard for sending per packet in a networked game? position and velocity, along with any important tidbits (direction, whatever)? and would this be sent over a single packet for each update, or would you split it so maybe absolute position updates come less frequently?[/QUOTE] I'd say where it's at right now and where it's going, so you can do some clientside motion prediction
Okay so I can not for the life of me figure out what is going wrong here. I'm programming in java, and I have to draw a fish as a polygon with these values from an array. it should work as far as I can tell, only when I run it I get this. [img]http://i.imgur.com/DLa51az.png[/img] [code] import java.awt.*; import javax.swing.*; public class Aquarium extends JPanel { public Aquarium () { int[] x = { 0, 18, 24, 30, 48, 60, 60, 54, 60, 48, 30, 24, 0 }; int[] y = { 0, 18, 6, 0, 0, 12, 18, 24, 24, 36, 36, 30, 36 }; int n = 13; Polygon p = new Polygon(x,y,n); setBackground (new Color(100,149,237)); setPreferredSize (new Dimension (1000,1000)); Fish fish1 = new Fish(Color.green, p); this.add(fish1); } } [/code] [code] import java.util.*; import javax.swing.*; import java.awt.*; public class Fish extends JPanel { Polygon fish; public int numPoints; Color color; public Fish(Color c, Polygon f) { color = c; int i = 0; fish = f; } public void paintComponent(Graphics g) { g.setColor(color); g.fillPolygon(fish); } } [/code] I'm fairly new to programming, so I'm probably missing something very obvious, but I can't figure it out. any help would save me from pulling my hair out. also I just realized there is some stuff in there I don't actually even use such as numPoints left behind from before. sorry 'bout that. forgot to clean the code up. [b]edit:[/b] no idea what was happening, but when i merged the aquarium class with the driver class it just fixed. oh well.
I'm trying to re-wrap my head around passing arguments from a loop to an asynchronous callback in javascript. I once had it down, but I forgot it and can't seem to figure it out again.
nevermind
Not really needing help with code itself, but can anyone give me an idea for a final project for my C++ class? I'm probably an intermediate coder, give me something I could preferably learn from while doing it
[QUOTE=raccoon12;39768390]Not really needing help with code itself, but can anyone give me an idea for a final project for my C++ class? I'm probably an intermediate coder, give me something I could preferably learn from while doing it[/QUOTE] An [URL="http://en.wikipedia.org/wiki/Enigma_machine"]enigma[/URL].
[QUOTE=raccoon12;39768390]Not really needing help with code itself, but can anyone give me an idea for a final project for my C++ class? I'm probably an intermediate coder, give me something I could preferably learn from while doing it[/QUOTE] Any particular fields that you have more experience in?
create a 3d spirograph thing
[QUOTE=ArgvCompany;39771645]Any particular fields that you have more experience in?[/QUOTE] I want to learn something math/graphics related. Something not too difficult to grasp, but will take some learning.
[QUOTE=Goz3rr;39759212]I'd say where it's at right now and where it's going, so you can do some clientside motion prediction[/QUOTE] my current test (top down, free to move around space shooter type setup) has it so that every x seconds (a tickrate period I guess, right now its set so it happens 20 times a second), the player sends a packet which resembles: "STATE UID PX PY VX VY DIR" STATE being a kind of "how to handle this" indicator, UID being the player index which the server assigned at login, P_ being the position vector (absolute), V_ the velocity vector and dir being the ship direction. locally, the player can thrust around applying an acceleration towards the cursor (which is where the ship points), and every update, the ships acceleration is stuck into the velocity and by extension, position of the ship - I guess this is called the state? every network tick described above, the server uses the received information to update the player's representation. the server periodically (its own tickrate) sends the state of every player globally, which clients use to update all the [I]other[/I] players the server and clients all iterate the player object's positions forward using the velocities between updates from the server so that they don't just teleport around every network tick as far as I can tell this is reaaaaaally trusting the client and would be insanely vulnerable to local and packet modifications (given this is just a test and the first time I've gotten something to move over the internets c: I think it'll do) so what do games now a days normally send? single packets every network tick with the local player's state, is it split into different packets for different information (position, velocity)? I've read the source networking wiki page (insanely good read, by the way), and it seems they send user keypresses to the server, and the server uses these in its own game code to move the player, while locally the keypresses are used to move the player right a way, then every update from the server, the player is shifted into accordance with the server.
[QUOTE=raccoon12;39772656]I want to learn something math/graphics related. Something not too difficult to grasp, but will take some learning.[/QUOTE] A 2d tile engine that you can edit the tiles in
How can I send projectile information over UDP? I was thinking about sending positions of each projectile each packet, but that would limit me to around 110 projectiles in total (each projectile would be positions X and Y, and angle, which is 12 bits). I was thinking of just sending a packet that says a player has fired a gun which created projectiles, and their location, but then how would I manage projectiles that change based on input, such as those that follow the user's cursor? Furthermore, what can I do if the packet containing the create projectile gets lost? If I have an ack, then how would this tie in with the case of projectiles that change based on input?
Sorry, you need to Log In to post a reply to this thread.