Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Munchor

Pages: 1 [2] 3 4 ... 20
16
OmnomIRC Development / OmnomIRC not working in Chromium Dev
« on: November 29, 2011, 10:59:32 am »
Hey guys (netham45), OmnomIRC is not working on the latest builds of Chromium. This might be either Chromium's fault (since it's from morning build), or OmnomIRC's, but I'm not sure. It works on Firefox under the same OS (Linux 3.1).

Cheers!

17
Computer Programming / Invalid array subscript
« on: November 09, 2011, 02:59:43 am »
Code: [Select]
#include <stdio.h>

using namespace std;

int main()
{
  int n;
  scanf("%d", &n);

  int avenidas[99];
  int ruas[99];

  int rua;
  int avenida;
  int pizzas;
  int i;
  for (i = 0; i < n; i++)
  {
    scanf("%d %d %d", &rua, &avenida, &pizzas);
    avenidas[avenida] += pizzas;
    ruas[rua] += pizzas;
  }

  int a = 7;
  printf("%d %d\n", avenida[a], rua[0]);
}

This is mostly C, but I'm using g++ to compile (I'll need C++ libraries later), and I'm getting this:

Quote
s.cpp:25:30: error: invalid types ‘int[int]’ for array subscript
s.cpp:25:38: error: invalid types ‘int[int]’ for array subscript

18
Humour and Jokes / Look at that calculator!
« on: November 08, 2011, 03:14:08 am »


The 84+!

19
Computer Programming / Reading tilemap algorithm
« on: October 22, 2011, 02:06:01 pm »
I have an issue that's been annoying me for some time now. I have to read a file to an bi-dimensional array.

The file looks like this:

Code: [Select]
1111111111111111111111111
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1000000000000000000000001
1111111111111111111111111

I am using the C library ('stdio.h') to read the file, and this is what I have so far.

Code: [Select]
int map[26][24];
int map_width = 26;
int map_height = 24;
int x;
int y;
FILE *map_file = fopen("map.txt", "r");
for (x = 0; x < map_width; x++)
{
  for (y = 0; y map_height; y++)
  {
     fscanf(map_file, "%d", &map[x][y]);
  }
  fscanf(map_file, "\n"); // Skip newlines
}

However, it doesn't really seem to be working, since I'm printing the array right after and it doesn't look like the file:

Code: [Select]
for (x = 0; x < map_width; x++)
{
  for (y = 0; y < map_height; y++)
  {
    printf("%d", map[x][y]);
  }
}

Thanks for the help!

20
Computer Programming / Passing a pointer to an array of an array
« on: October 22, 2011, 05:46:06 am »
I need some help with a pointer problem I'm facing. I have this:

Code: [Select]
int my_array[26][24]; /* An 2 dimensions array */

call_function(NEED_HELP_HERE);

call_function() requires an argument, an array. I need to pass my_array. However, I know that passing arrays in functions is memory consuming and not very clean. So, instead, I want to pass a pointer to the array.

So my question is how to declare the pointer to the array, how do I declare it?

Code: [Select]
void call_function(NEED_HELP_HERE)
{
  /* This function receives a pointer to an array as argument */
}

The question is what to put in "NEED_HELP_HERE" places. My issue is that I don't know what type the pointer to the array of arrays is.

Thanks in advance!

21
Miscellaneous / Which language should I use?
« on: October 16, 2011, 04:42:12 pm »
I had an idea for a computer game (it can't really be made for calculators that I have :(), I won't give many details, but I can say the following:

* It's a maze game;
* It's a strategy/thinking game;
* It requires a tilemapping system;
* It requires colours and images;
* It requires sound;
* Close source is a +, unlike all of my other software;

So I thought of the following ways of making it:
- Use the playn library so that I can code it in Java and have it released for Android, HTML5, Java and Flash;
- Use C/C++ with SDL and have it released for all operating systems;
- Use Java and have it released both as a Web App and a desktop App;
- Use HTML5/Javascript; (too complicated)

It's basically Java vs C++... With C++ I can make sure it's closed source and make it fast. But if it were Java, I could distribute Web Applications, and that would be cool, so that people don't have to make downloads. Oh! And I can use Java with playn or Java without playn, that's also a problem.

What do you think? Thanks!

22
Art / [Request] Lobster Sprite
« on: October 09, 2011, 01:18:35 pm »
Hey everyone, I need a sprite for a project Jim Bauwens and I have been working on.

I need a lobster sprite. However, it gets quite complex because its height can't be higher than 21.

Well, here are some of the details:
  • Maximum height: 21 pixels
  • Maximum width: it doesn't exist, but preferably below 40
  • Colors: blue and purple

I would like the lobster to be laid down, stomach faced down. The colours are more or less the ones in the Omnimaga Title, where it says "THE CODERS OF TOMORROW".

I don't think this is very easy to do, but you'll be credited, and I'll thank you tons if you can make it, thanks!

23
Web Programming and Design / onmousemove and onmousedown
« on: October 02, 2011, 03:15:42 pm »
I have this function, that's called by onmousemove="checkmouse(event)"; in body.

Code: [Select]
function checkmouse(event)
{
  var x = event.clientX - drawingCanvas.offsetLeft;
  var y = event.clientY - drawingCanvas.offsetTop;

  context.fillRect(x, y, 5, 5);
}

I was wondering how I can check if the mouse is both moving and down. I can do them separately (onmousemove or onmousedown), but not together. Do you have any ideas? Thanks.

24
Computer Programming / C string with numbers for a label
« on: October 02, 2011, 07:24:12 am »
I am using GTK+ to create a label with numbers on it:

Code: [Select]
time_text = gtk_label_new("Time: %i:%i:%i", hours, minutes, seconds);
The gtk_label_new function takes a const gchar *str as argument. However, when compiling the code, I get:

Quote from: GCC
error: too many arguments to function ‘gtk_label_new’

This is because I am passing four arguments to gtk_label_new.

So I need to pass only one string, but I need the numbers included (hours, minutes, seconds).

Any idea? Thanks!

25
Web Programming and Design / Change data attribute of object in html
« on: September 24, 2011, 04:52:27 am »
I am using Javascript (with jQuery) to change the attribute of an object tag, the "data" attribute.

Here's the HTML code:

Code: [Select]
<div id="content">
  <object id="text" width="600" height="450" type="text/html" border="0" style="overflow: hidden;"></object>
</div>

That is a simple object within a div, an HTML object. I want to link it to file, using the [/tt]data = "file.html"[/tt] attribute.

Code: [Select]
$(document).ready(function() {
  $('#text').attr('data', "hometext.html");
});

So this should make it so that when the page is ready, the "text" object data is set to "hometext.html".

However, nothing is really happening, because linking "hometext.html" to the object data should display the contents of "hometext.html" in its location.

If I manually go to the HTML code and set data="hometext.html" it works, but not through jQuery.

How can I do it? Thanks!

26
Web Programming and Design / Horizontal Fade on both edges
« on: September 20, 2011, 01:51:51 pm »
My CSS knowledge is very poor, and so I need help with something.

I need a website to be white on the middle background and fade to gray on the edges. I got an image which is gray fading to white, and made it repeat itself on the left:

Code: [Select]
  background-repeat: repeat-y;

However, I need to achieve the same result (with an inversed image) on the other edge. How can I do it?

Thanks, here's how it should look like (Ascii Art :P)

GgggwwwwwwwgggG

G = Gray, W = white

27
Computer Programming / Java Panel/Frame has different sizes
« on: September 13, 2011, 12:05:17 pm »
I have this code:

Code: [Select]
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

public class Game extends JPanel implements KeyListener {
  /* Game Panel class containing all functions */

  JFrame mainFrame = new JFrame("Game");
  boolean needs_repaint;

  public void paintComponent(Graphics g) {
    /* Draws the elements on the screen */
    super.paintComponent(g);

    System.out.printf("Panel Width: %d\n", this.getWidth());
    System.out.printf("Frame Width: %d\n", this.getParent().getWidth());

    /* Repainting has finished */
    needs_repaint = false;
  }

  public void update() {
    /* Main game loop */
   
    /* Always repaint */
    //this.repaint();
  }

  public void run() {
    /* Displays the frame, start the game */
    mainFrame.setVisible(true);
    this.requestFocus();
  }

  public Game() {
    /* Defines the frame and the game panel */
    this.setFocusable(true);
    this.addKeyListener(this);

    /* Fixed Layout frame */
    mainFrame.setSize(852, 600);
    mainFrame.setResizable(false);
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.getContentPane().add(this);   // Add game panel to main frame

    /* Start timer with main game loop */
    Timer timer = new Timer(25, new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        update();
      }});
    timer.start();
  }

  /* Game Class is not abstract, and these functions are not needed */
  public void keyPressed(KeyEvent key) {}
  public void keyReleased(KeyEvent arg0) {}
  public void keyTyped(KeyEvent arg0) {}
 
  public static void main(String[] args) {
    new Game().run();
  }
}

Basically, what happens is that the frame and the panel not always have the same width. This happens in my game Falling Blocks and with the above code as well. Below is what happened when I ran the program several times (it's a bit random, sometimes it has 850, other times it has not).

I have no idea of how to fix this, since my code supposedly gives the frame a fixed size of 852.

Quote
david@davidbuntu:~/temp$ java Game
Panel Width: 850
Frame Width: 850
Panel Width: 850
Frame Width: 850
Panel Width: 842
Frame Width: 842
Panel Width: 850
Frame Width: 850
david@davidbuntu:~/temp$ java Game
Panel Width: 850
Frame Width: 850
Panel Width: 850
Frame Width: 850
david@davidbuntu:~/temp$ java Game
Panel Width: 850
Frame Width: 850
Panel Width: 850
Frame Width: 850
david@davidbuntu:~/temp$ java Game
Panel Width: 836
Frame Width: 836
Panel Width: 842
Frame Width: 842
Panel Width: 836
Frame Width: 836
david@davidbuntu:~/temp$

EDIT: As you can see I also set mainFrame to not resizable, so I'm not resizing it.

28
Miscellaneous / Eclipse, autocomplete everything
« on: September 13, 2011, 10:11:22 am »
I did some online research on how to make it so that Eclipse suggests autocompletion for every single word written in my opened documents.

This is a feature that would really help me coding, but I couldn't find it online. I'm asking for help because I'm wondering if some of you know how to do it. Thanks :)

29
Miscellaneous / Coding Font
« on: September 12, 2011, 10:39:17 am »
I know there's a topic on something similar here but this is different.

What is your favourite coding font? The one you use on your programming text editors.

I use Consolas or Courier New, what about you ;)

30
Computer Programming / Picture Rotating
« on: September 12, 2011, 06:14:18 am »
This is a general programming question. I chose to put it here, because I'm using Java.

I need to display an image, and that image can rotate with the mouse. Basically, it's like Builderboy's game Nightmare, where the player has an orientation and he is always looking at the location of the mouse.

I'm not asking for Java code, I'm asking about how to make it.

Code: [Select]
int orientation;
int x;
int y;

These are the three main variables of the player object. My problem is how to display an image with a certain rotation.

If the player were a rectangle, I would display it like this:

Code: [Select]
/* g is the graphics component */
g.fillRect(x, y, 20, 20);

Now, how can I rotate the rectangle? My only obvious answer is using trigonometry, it's not very hard, but I'm wondering if there are any other ways. Thanks a lot!

Pages: 1 [2] 3 4 ... 20