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 5 ... 20
31
Web Programming and Design / [PHP] Checking if file was submitted
« on: September 11, 2011, 03:24:49 pm »
Code: [Select]
<form action="upload.php" method="POST" enctype="multipart/form-data">
  <input type="file" name="file" id="file"><br>
  <input type="submit" name="submit" value="Submit">
</form>

I have this form and I would like to know, in the upload.php file if anything was submitted in the type="file".

This tells me nothing was submitted, even when I submitted a file:
Code: [Select]
<?php
  
if (empty($_FILES["file"]["file"]))
  {
    echo 
"No file was submitted, try again.";
  }
?>


This also tells me nothing was submitted, even when I submitted a file:
Code: [Select]
<?php
  
if (empty($_POST["file"])
  {
    echo 
"No file was submitted, try again.";
  }
?>


Thanks in advance!

32
Let's say I have this HTML file:

Code: [Select]
<!doctype html><html>
  <head>
    <title>My Page</title>
  </head>

  <body>
    <form action="handler.php" method="post">
      <p><input type="text" name="text" id="text" /></p>
      <p><input type="submit" value="Go" /></p>
    </form>
  <body>

</html>

And then I have this file (handler.php):

Code: [Select]
<?php
  $text 
$_POST["text"]; //gets the text from the text field
?>


Basically, it's a very simple form. How can I know the name of the file that called the .php file?

I want to get it's URL, is there a way I can do this? Thanks!

33
Ndless / Ndless 3 and access to Wireless
« on: September 08, 2011, 05:20:10 pm »
If Ndless 3 ever comes, is there a chance we can use the Wireless for cool stuff?

I think yes, at least in ASM I'm pretty sure we can.

Thanks ;)

34
Humour and Jokes / [NSFW] Monkeys are crazy
« on: September 08, 2011, 06:55:30 am »


I laughed so much :P

35
http://saucelabs.com/

I just found that really cool company, they made something called Sauce Cout, that lets you browse websites in different browsers, from inside their webpage, it's pretty cool, it features IE 6 too!

I hope you find it useful ;)

36
Miscellaneous / Collision in Games
« on: September 06, 2011, 05:45:46 am »
The very first games I coded were made in Axe, so I got used to doing pixel-level-perfect collision, because it was the best way for it. However, as I want to start developing games on larger scales, I need some help understanding how collision is done on engines that have objects moving at speeds faster than one pixel at a time.

For example, the attached video is a program of mine own, made in Python. It's a simple physics engine, but the block never has a speed bigger than one pixel, and I am using Fixed Point (x256) to get more precision.

I know, though, that on larger games objects need to move faster, but collision still works pretty well.

Code: [Select]
X = X + HORIZONTAL_ACCELERATION;
Y = Y + VERTICAL_ACCELERATION;

Basically, what I thought was. Instead of doing the code above, do:

Code: [Select]
While i < HORIZONTAL_ACCELERATION
  Check_Collision();
  X++
End

So, I thought I could add a bit of acceleration at a time, and check for collision all the time. However, I'm not sure if this is a very good idea, because I can't do X++. Sometimes, acceleration is negative.

I'm wondering if any of you has any idea of how collision is done on games, thanks!

37
Computer Projects and Ideas / Java - Falling Blocks
« on: September 05, 2011, 05:20:04 pm »
I decided to port the Falling Blocks game I made for the TI Nspire Game Contest to computers, and I made it in Java, with a screen of 852*600. The graphics are as simple as the ones of the original game. It's almost an exact port, I wanted to keep it fast and simple, like the original.

Here's a couple of screenshots of it running. Oh and it's open-source, the source is included.


Blocks falling in the title screen


"Deathly" blocks are read, and the other are green

On the attached zip, "FallingBlocks.class" is the main class, so to run it, just do java FallingBlocks, or open FallingBlocks.class using the Java Runtime program, if you prefer to do it with the mouse.

38
Computer Programming / [Java] Timer inside event-based class
« on: September 04, 2011, 04:03:35 pm »
Code: [Select]
import java.awt.Graphics;
import java.awt.event.*;

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 */

  /* Global static variables */
  JFrame mainFrame = new JFrame("Falling Blocks");
  int y = 520;
  int[] locations = {0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800};

  /* Global dynamic variables */
  int a; //Horizontal acceleration
  int x;
  boolean needs_repaint;
  boolean on_title_screen, on_game, on_game_over;

  public void init_variables() {
    /* Initates the dynamic variables in order to show Title Screen */
    a = 0;
    x = 0;
    on_title_screen = true;
    on_game = false;
    on_game_over = false;
    needs_repaint = true;
  }

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

    if (on_title_screen) {
      g.drawString("Press SPACE to start game", 10, 10);
      g.drawString("Made by David Gomes", 10, 30);
    }

    else if (on_game) {
      //Draw the player
      g.fillRect(x, y, 50, 50);
    }

    else { //Game Over
      g.drawString("Game Over", 10, 10);
    }

    //Repainting has finished
    needs_repaint = false;
  }

  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);
    // Add game panel to main frame
    mainFrame.getContentPane().add(this);
  }

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

  @Override
  public void keyPressed(KeyEvent key) {
    /* Handles key presses */

    if (on_title_screen) {
      /* Start the game when user presses SPACE */
      switch (key.getKeyCode()) {
      case KeyEvent.VK_SPACE:
        on_title_screen = false;
        on_game = true;
        needs_repaint = true;
        break;
      }
    }

    else if (on_game) {
      switch (key.getKeyCode()) {
      case KeyEvent.VK_LEFT:  // Move x coordinate left
        if (x > 0) {
          x -= 50;
          needs_repaint = true;
        }
        break;

      case KeyEvent.VK_RIGHT: // Move x coordinate right
        if (x < 800) {
          x += 50;
          needs_repaint = true;
        }
        break;
      }
    }

    else { // Game Over
      init_variables(); //Go to title screen
      needs_repaint = true;
    }

    // Repaint only if needed
    if (needs_repaint)
      this.repaint();
  }

  /* Game Class is not abstract, and these functions are not needed */
  @Override
  public void keyReleased(KeyEvent arg0) { }
  @Override
  public void keyTyped(KeyEvent arg0) { }
}

I have that code (with syntax highlighting here), and I need to add a timer inside the Game class, associated with a function that runs every N seconds. And I need it to run at the same time as other functions run in the class (keyPressed, paint), etc.

I found a lot of information online on how to make timers in Java (javax.swing.Timer class and other ways), but I don't think it allows me to have the other functions running inside the class too. And I also don't know how to implement it in this specific context.

I appreciate any help, thanks!

39
Axe / Axe Tilemapping and Optimization
« on: September 03, 2011, 01:19:47 pm »
I started a project for the Axe Progamming Contest but I soon quit it because of tilemapping, because I didnt't find a way of not having to redraw all the screen all the time, which made my game run quite slow.

Here's the full code (without tilemapping, I use graphing commands to design the map):

Code: [Select]
.A
#Icon(FFFF8001BC3DA5E5A525BD2581E59C3D95C19D7981C9BE89A289BEF98001FFFF)
[E0E0808000000000]->Pic1
ClrDraw^^r
Fix 5
1280->X
10240->Y
0->A->B
24->C
20->E
Repeat getKey(15)
  .CHECK IF USER IS TOUCHING FLAG
  If (X/256-C+4<=8) and (Y/256-E+4<=8)
    Return
  End

  .CHECK IF ENEMY ON THE LEFT
  0->J
  For(I,0,3)
    If (pxl-Test(X/256-1,Y/256+I)^^r)
      1->J
    End
  End

  .CHECK IF ENEMY ON THE RIGHT
  0->K
  For(I,0,3)
    If (pxl-Test(X/256+4,Y/256+I)^^r)
      1->K
    End
  End

  .CHECK IF ENEMY ON TOP
  0->M
  For(I,0,3)
    If (pxl-Test(X/256+I,Y/256-1)^^r)
      1->M
    End
  End

  .CHECK IF ENEMY BELOW THE PLAYER
  0->N
  For(I,0,3)
    If (pxl-Test(X/256+I,Y/256+4)^^r)
      1->N
    End
  End

  .IF AN ENEMY IS TOUCHING THE PLAYER
  If (N) or (M) or (J) or (K)
    Return
  End

  .CHECK IF WALL ON THE LEFT
  0->L
  For(I,0,3)
    If (pxl-Test(X/256-1,Y/256+I))
      1->L
    End
  End

  .CHECK IF WALL ON THE RIGHT
  0->R
  For(I,0,3)
    If (pxl-Test(X/256+4,Y/256+I))
      1->R
    End
  End

  .IF ANYTHING ON THE RIGHT OR ON THE LEFT, STOP
  If L or (R)
    0->A
  End

  .CHECK IF ANYTHING UNDER THE PLAYER
  0->D
  For(I,0,3)
    If (pxl-Test(X/256+I,Y/256+4))
      1->D
    End
  End

  .GRAVITY
  B+5->B
  For(I,0,3)
    If pxl-Test(X/256+I,Y/256-1+(B>>0*5))
      0->B
    End
  End

  .GO LEFT
  If getKey(2) and (A>>~255) and (L=0)
    A-32->A
  End

  .GO RIGHT
  If getKey(3) and (A<<256) and (R=0)
    A+32->A
  End

  .JUMP WHEN USER PRESSES UP
  If getKey(4) and (D)
    ~256->B
  End

  .WALL JUMP ON THE LEFT
  If (R) and (D=0) and (getKey(2)) and (getKey(4))
    ~100->B
    A-40->A
  End

  .WALL JUMP ON THE RIGHT
  If (L) and (D=0) and (getKey(3)) and (getKey(4))
    ~100->B
    A+40->A
  End

  .LIMIT SPEED AT 1 PIXEL
  If (B>>256)
    256->B
  End

  .FRICTION
  If A-1=>=>0
    A-2->A
  End

  .FRICTION
  If A//32768
    A+2->A
  End

  .UPDATE POSITIONS
  X+A->X
  Y+B->Y

  .DRAW THE MAP
  Rect(0,0,96,64)
  RectI(4,4,88,56)
  Rect(20,24,12,4)

  .DRAW THE PLAYER
  Rect(X/256,Y/256,4,4)

  .DRAW THE FLAG
  Pt-On(C,E,Pic1)

  DispGraph^^r
End

Basically, enemies are whatever is gray on the screen, so if the player touches something gray, the game stops.

There are two things I need help with:
  • Implementing tilemapping to draw levels in a way that doesn't make the game too slow
  • Make it so that the user doesn't go through walls when jumping

Here's a screenshot of the second:



I made this code a few weeks ago, so I don't exactly remember how everything works, but from what I understand, I'm never checking if there's anything above the player, am I?

I know my help request sounds a bit vague, but it's hard to make it more specific.

40
Computer Usage and Setup Help / Acer Aspire 5520 doesn't boot
« on: August 19, 2011, 10:42:12 am »
I have an Acer Aspire 5520 in my house that doesn't boot, but I never bothered to look around and try to fix until today.

Basically, here's what happens:
1. Press the ON button
2. Nothing happens (no sound, no light, no beep, no reaction at all!)

I tried doing this either using AC Power and Battery Power, and AC Power with Battery removed too.

When it has the battery inside and the cable is connected, the Battery LED (meaning it's charging) goes red. This is the only thing that works in the computer.

Since it doesn't boot (not even BIOS, as I said nothing), I have absolutely no idea of what to do. Other people online have problems with this computer, but no problem like mine.

If you have any ideas, I'd appreciate them, thanks!

41
Computer Programming / [Java] Adding graphics to frame
« on: August 18, 2011, 12:25:15 pm »
I was just trying to add Graphics2D to a Frame this way:

Game.java
Code: [Select]
import java.awt.Component;

public class Game
{
public static void main(String[] args)
{
MainFrame mainFrame = new MainFrame();
MainGraphics mainGraphics = new MainGraphics();
mainFrame.getContentPane().add(mainGraphics);
}
}

That file contains the main function, where I create a new frame and a new graphics (both classes made in separate files), and then I try to add the graphics to the frame.

The problem is, though, I get:

Quote
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
   Cannot instantiate the type MainGraphics
   The method add(Component) in the type Container is not applicable for the arguments (MainGraphics)

I can only add components to frames and content panes.

So I tried to make mainGraphics a component, like this:

Code: [Select]
Component mainGraphics = new MainGraphics();
However, I get (in this line):

Quote
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
   Type mismatch: cannot convert from MainGraphics to Component
   Cannot instantiate the type MainGraphics

Does anybody know how to solve this? Thanks! Also, MainGraphics is an abstract class, here's its code:

Code: [Select]
import java.awt.Graphics2D;


public abstract class MainGraphics extends Graphics2D {
public MainGraphics()
{
this.create();
this.drawLine(5, 5, 10, 10);
}
}

42
TI-Nspire / LunaGUI - A Linux GUI Tool to use Luna
« on: August 16, 2011, 10:16:41 am »
After Adriweb made a Mac Application to make it easier to use Luna with a simple GUI interface, I decided to make a Linux version together with Spyro.

Mine uses Python and wxPython, and below is a screenshot of it on Ubuntu 11.04:



Note, though, that in order to use this tool, you need "luna" on the same directory as the attached file. Luna was made by ExtendeD, so it's not attached with LunaGUI. To run LunaGUI, you need Python 2.6 or Python 2.7 and wxPython 2.8.

43
Does any of you know any guide on how to design programs that run well on mobile browsers? Thanks.

I'd also like to know how this kind of URL's work:

http://www.omgubuntu.co.uk/about/

The page has to have a file name, like about.php or about.html, so how do they hide the file name?

I thought that maybe they use Javascript to change the URL in the window, is that how they do it?

Thanks.

44
Computer Programming / C++ GetLine for input
« on: August 13, 2011, 06:15:18 am »
I was tried to make a program that read X lines of input by the user and saved each line on a string.

However, if I tell it to get input 5 times, it only gets input 4 times.

Code: [Select]
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int d, n, i;
  cin >> n;

  string line[n];
  for (i = 0; i < n; i++)
  {
    getline(cin, line[i]);
  }
 
  cout << endl;
 
  for (i = 0; i < n; i++)
  {
    cout << line[i] << endl;
  }
 
 
 
  return 0;
}

Basically, if I input "5" to the variable "n", it gets input 4 times, instead of 5.

What is the problem?

Thanks!

45
General Discussion / [Sort of NSFW] Coldplay, Weird Music Video
« on: August 12, 2011, 01:52:05 pm »


Good song, but it's the video I'm interested it, what is he doing to the piano  :crazy:

Also, this is the Coldplay's song I most like :) Some of them look like "forced hits" to me, but this one is good.

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