• What do you need help with? V4 (January 2012)
    966 replies, posted
[QUOTE=ZachPL;34534433]I just started a class programming in C and C++ and I was trying to write like a super basic program and I am having problems getting the equation part of the code to execute... [code]# include <stdio.h> int main(void){ float celsius, fahrenheit; printf("Please enter a temperature in degress Fahrenheit: "); scanf("%f", &fahrenheit); celsius = [b](5f / 9f)[/b] * ( (float) fahrenheit - 32f); printf("The temperature of %f in degrees Celsius is %f.\n", fahrenheit, celsius); return 0; } [/code] It just gives me zeros as the answer. I'm sure it is something really simple I just have basically no experience :P Thanks![/QUOTE]You have to add an f to the end of the 5 and 9, otherwise it'll give 0 because it does integer division.
-snip- Anyways, for the c# winform guys here, is there a stigma against explicitly calling click events inside your program?
[QUOTE=Octave;34534654]You have to add an f to the end of the 5 and 9, otherwise it'll give 0 because it does integer division.[/QUOTE] I removed the float and just added .0 to all the integers to make them floats and then it worked. Thanks for the help.
So i have two Vector3 values in XNA. They are a 3D camera's position and target. How can i rotate the target vector around the position and keep it at a constant distance from the position all the time? [editline]lol[/editline] Also, how do i do collision with vertices and the camera's position?
XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread) Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?
[QUOTE=ZachPL;34534851]I removed the float and just added .0 to all the integers to make them floats and then it worked. Thanks for the help.[/QUOTE] That actually makes them doubles. Just saying.
-whoops-
[QUOTE=Funley;34539858]So i have two Vector3 values in XNA. They are a 3D camera's position and target. How can i rotate the target vector around the position and keep it at a constant distance from the position all the time? [editline]lol[/editline] Also, how do i do collision with vertices and the camera's position?[/QUOTE] Here's a camera class I wrote for a free moving camera in XNA, and the Particle class it extends from. [url]http://pastebin.com/zu0XMMNP[/url] [url]http://pastebin.com/TGeUcX5X[/url] It uses a combination of a Vector3 for the change in rotation values, and updating a matrix based on them. You can then use that matrix's forward vector and multiply it (or not) to get your target. It's all in the UpdateViewMatrix function.
[QUOTE=DestWa;34539883]XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread) Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?[/QUOTE] I second this question. Of course most will say to program roguelikes in some form of Curses with c++.
You can make a rougelike using literally anything you have, as long as you can output things. I suggest XNA since you know it already, but I am unfamiliar with pygame so I might be biased.
Snip, wow oops. Wrong thread.
So I've got this dylib that I want to dynamically link against another dylib. Anyone know how I can do that? [editline]5th February 2012[/editline] Also, the other dylib doesn't have 'lib' in its name...
Snip: OpenGL and me do not agree. I am forcing OpenGL to agree with me instead of retreating to DirectX.
How can i do collisions with a Vector3 (XNA) and many, many vertices? [editline].[/editline] Help please?
So I'm learning java because I heard that it's the standard language in universities (I plan to move to C++ when i'm done) But i'd like to see some example programs made in java so I could know what i'm working towards. If anyone has anything impressive that they made in java I would love it if you showed me.
I'm trying to use Tesseract in VB.NET, and whenever I try to call Init, it either closes without a message, or it says this: [img]http://speedcap.net/img/aadeb96bb708a2e5bceb75a7a95c8002/ddd10cfb.png[/img] [code] Try Dim T As New Tesseract Using O As New OpenFileDialog With O If Not .ShowDialog = DialogResult.Cancel Then Dim B As Bitmap = New Bitmap(.FileName) T.Init(Application.ExecutablePath, "Eng", False) Dim L As List(Of Word) = T.DoOCR(B, Rectangle.Empty) For Each w As Word In L MessageBox.Show(w.Text) Next End If End With End Using Catch Ex As Exception MessageBox.Show(Ex.Message) End Try [/code] I seriously don't know what's wrong with it. [editline]5th February 2012[/editline] Okay, this shit is starting to piss me off. Is there seriously not one free fucking OCR library that isn't absolute garbage? Getting these retarded fucking errors with Puma.NET [img]http://speedcap.net/img/aadeb96bb708a2e5bceb75a7a95c8002/1a761b07.png[/img] I'm about to punch a hole in my monitor
[QUOTE=TheCloak;34560515] Okay, this shit is starting to piss me off. Is there seriously not one free fucking OCR library that isn't absolute garbage?[/QUOTE] From my experience, no, there isn't.
Potentially stupid question time. How do you get rid of the gradient and shadow Xcode applies to tab bar images in an iOS app? I've changed the images for the bar items by selecting an imported one in the storyboard, and that just adds the effects (as expected). I'm assuming I'd have to go into AppDelegate.m and set up something like this: [code] // Customize the Home bar item UIImage *barItemHome = [[UIImage imageNamed:@"home.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; [[UIBarItem appearance] setBackgroundImage:barItemHome forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [/code] This doesn't work, though, and even if it did I have no way of selecting just the "Home" bar item to apply it to and not all of the icons. Google hasn't helped me as all of the tutorials seem to work only for older iOS versions since iOS 5 decided to fuck with the way everything is called.
Is there a way to force visual C++ to include macro's in a static library. For example: lib.h: [code] void doStuff(); [/code] lib.cpp: [code] #include "lib.h" #ifdef useint void doStuff() {int bloop;} #else void doStuff() {bool bloop;} #endif [/code] App.cpp: [code] #define useint #include "lib.h" int main() {doStuff()} [/code] I say this because I am building an engine and I would like to define these macros per-build. [editline]5th February 2012[/editline] [QUOTE=DestWa;34539883]XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread) Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?[/QUOTE] IF you want to make a text based game you want to just make a console application like a C++ console application using cout and cin and such.
I'm sort of tired, so I must be making a really stupid mistake, but here it goes. [code] unsigned char m1[]="abc"; unsigned char m2[64]; for(int i=0; i<64; i++){ m2[i]='a'; } printf("%s\n",m1); printf("%s\n",m2); [/code] Output: [code]abc aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaÌÌÌÌÌÌÌÌabc[/code] What's going on with the second line?
You're missing the null terminator. ( \0 ) The second line is actually 75 characters long because of that.
[QUOTE=flayne;34566789]Is there a way to force visual C++ to include macro's in a static library. For example: lib.h: [code] void doStuff(); [/code] lib.cpp: [code] #include "lib.h" #ifdef useint void doStuff() {int bloop;} #else void doStuff() {bool bloop;} #endif [/code] App.cpp: [code] #define useint #include "lib.h" int main() {doStuff()} [/code] I say this because I am building an engine and I would like to define these macros per-build.[/QUOTE] that's not how it works, it goes by whatever macro is defined when lib.cpp is compiled. If you [i]really[/i] want to do what you're trying, do something like this: [b]lib.hpp[/b]: [cpp] _doStuffInt(); _doStuffBool(); static void doStuff() { #ifdef useint _doStuffInt(); #else _doStuffBool(); #endif } [/cpp] [b]lib.cpp[/b]: [cpp] void _doStuffInt() {int bloop;} void _doStuffBool() {bool bloop;} [/cpp] (also, please don't use .h for C++ header files)
[QUOTE=ief014;34568936]You're missing the null terminator. ( \0 ) The second line is actually 75 characters long because of that.[/QUOTE] Thank goodness for Facepunch help, you can always count on someone to get a response to you quickly. Sometimes after working on a bunch of code you just need a fresh pair of eyes. You're absolutely correct, I can't believe I made such a mistake with c-style strings. The example above is a simplified version of what I'm actually dealing with, although I did narrow down the problem to that piece of code. In reality both m1 and m2 are hashes of data that might have multiple null-terminators in them, and the loop is a transformation on one of the hashes.
In Java, how would one go about targeting the surface of a JFrame?
[QUOTE=Sir Whoopsalot;34570470]In Java, how would one go about targeting the surface of a JFrame?[/QUOTE] what do you mean by targeting and what do you mean by surface? You could replace the content frame with your own component and override drawComponent if that's what youre trying to do
I've been working with SharpDevelop for C#, but I recently got another monitor, and although you can use vertical tabs to see more of the code/ other windows, is there any way to bind or link the scrollbars of the different windows so that when I scroll it in one it can scroll it as a whole? If not in SharpDevelop, are there any IDE's that might?
-Snip- cPannel is buggy ......
I have a problem where the same free space is assigned to different structures in MarsMiner's saving system. Can you please have a look at [URL="https://github.com/Tamschi/MarsMiner/blob/reusable-space-attempt/MarsMiner.Saving/Util/IntRangeList.cs"]https://github.com/Tamschi/MarsMiner/blob/reusable-space-attempt/MarsMiner.Saving/Util/IntRangeList.cs[/URL] and tell me whether the conditions are correct? The IntRangeList is supposed to store non-overlapping number ranges (inclusive start, exclusive end). [b]Edit:[/b] Fixed it. One missing line. :suicide:
Ok this is really bugging me! [code] 1 ItemNumber int(11) 2 ItemName varchar(100) latin1_swedish_ci 3 Price double 4 AvailableQuantity int(11) 5 Updated_Dt datetime [/code] [code] private void Form1_Load(object sender, EventArgs e) { //Initialize mysql connection connection = new MySqlConnection(ConnectionString); //Get all items in datatable DTItems = GetAllItems(); //Fill grid with items dataGridView1.DataSource = DTItems; } //Get all items from database into datatable DataTable GetAllItems() { try { //prepare query to get all records from items table string query = "select * from items"; //prepare adapter to run query adapter = new MySqlDataAdapter(query, connection); DataSet DS = new DataSet(); //get query results in dataset adapter.Fill(DS); [/code] It shows the data that is on the Database fine [code] // Set the INSERT command and parameter. adapter.InsertCommand = new MySqlCommand( "INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());", connection); adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1"); adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName"); adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price"); adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity"); adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None; [/code] I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this. "Column 'ItemNumber' cannot be null" [editline]7th February 2012[/editline] Ok this is really bugging me! [code] // Set the INSERT command and parameter. adapter.InsertCommand = new MySqlCommand( "INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());", connection); adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1"); adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName"); adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price"); adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity"); adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None; [/code] I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this. "Column 'ItemNumber' cannot be null" I don't know if this adds anything but I just dragged a datagriview1 onto the form, didn't modify it in anyway.
Style question for you guys (Keep in mind i'm coding in c#) How do you capitalize fields, properties, methods and parameters? The style I've been using it to use camelCase for private fields and parameters. Public properties and methods are PascalCase. Also, typically when does one add a "_" before a field (or is it method?) I've seen that before as well.
Sorry, you need to Log In to post a reply to this thread.