Arpssss
Arpssss

Reputation: 3858

How to include Header File (.h) in Java

I want to use this which says to use a particular method I have to include tcutil.h in my java code. Can anybody help me, how to do that ? Another point: we can easily create an header file and include it in to C code but why reverse is so hard (means lots of work have to do) ? May be stupid, but little bit hints will be helpful.

Upvotes: 0

Views: 12942

Answers (7)

user21449527
user21449527

Reputation: 1

you will be programming a basic game that features a playable character and some simple mechanics such as collision detection.

Canvas

The canvas should be a square that is 700 pixels in width and 700 pixels in height.

Character design

You will need to come up with a design for your playable character. In the demo the playable character is a spider which is drawn using multiple lines and an ellipse. You are free to design your character however you like (or copy the spider design from the demo). For full marks your character must be a complex shape drawn using at least 3 simple shapes. You must also use at least 2 different types of simple shapes. For example, a character that is drawn using 2 rectangles and a line OR a character drawn using two triangles and a circle would both suffice. The character’s overall dimensions should be approx. 70 pixels in width and 70 pixels in height.

Movement

Have the character be controlled using the arrow keys in the following manner:

✰ The UP arrow key moves the character up 70 pixels.

✰ DOWN moves the character down 70 pixels.

✰ LEFT moves the character to the left 70 pixels.

✰ RIGHT moves the character to the right 70 pixels.

The character should be centered on the point (35, 35) at the start of the program. This is to ensure that the character moves correctly. Please refer to the demo video to see what moving correctly looks like.

Note that you cannot use the WASD keys to move the character, the character MUST be controlled using the arrow keys.

Boundaries

The character must be prevented from moving off the canvas. For half marks, prevent the character from being moved beyond a canvas boundary.

when the character is moved beyond a canvas boundary have the character appear against the opposite boundary. This is a recreation of the same boundary mechanic used in Pac-Man. Please see the demo video for a visual depiction of this feature.

Trail

There needs to be some kind of trail extending vertically from the character’s position to the top of the canvas. In the demo there is a white line extending vertically from the spider to the top of the canvas to represent the web the spider is swinging from. You are free to change the theme of this trail, but it must behave in the same way. That is, it must extend vertically from the character to the top of the canvas AND it must move as the character moves.

Obstacles

Have two obstacles present somewhere on the canvas. Their positions should be randomly generated. This means that each time the program is run the obstacles will appear in different positions. You are free to design the obstacles however you like, but it’s best to keep them rectangular.

There must be some visual indication that the game is over when the character collides with an obstacle. In the demo, the canvas is cleared and the text “game over” is displayed. You are free to design your own game over screen.

  1. Constraints

✘ You cannot use any extra processing libraries or plugins.

✘ You cannot define your own classes.

✘ The only built-in java classes you can use are PVector and PShape. Although, we recommend not using them.

✘ You cannot use multiple tabs or multiple files.

✘ You cannot use transformations such as rotate, translate, scale etc.

✘ You cannot use images.

✘ You cannot import fonts.

✔ You must submit a single .pde file named exactly COMP1000.pde (not COMP 1000.pde, not COMP1000 (1).pde, not yudip1.pde...).

Upvotes: -1

Christian Schlichtherle
Christian Schlichtherle

Reputation: 3155

The page mentions that there is an API for Java available, but does not show it. You should ask them for the Java documentation. Preferrably, the API should be a JDBC driver.

Upvotes: 1

stacker
stacker

Reputation: 68972

This might be more complicated than you think. The .h files are C language include files which usually describe the methods and data structures of a C-library. You would have to Java Native Interface (JNI) in order to include these libraries in your java code.

You have basically two options

  • Go through a tutorial like this

  • Or look for a java implementation.

There're already java-bindings available.

Upvotes: 1

Alexey Berezkin
Alexey Berezkin

Reputation: 1543

To run native code from Java, you need using JNI technology. Try http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html or http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/functions.html of google by keywords "JNI, tutorial".

Upvotes: 1

Kamal
Kamal

Reputation: 1122

you cannot do it directly in java. You have to include the header files in your C program and use JNI to call the functions that you want to use.

Refer this : JNI reference

Upvotes: 1

assylias
assylias

Reputation: 328735

They seem to have a Java API, which you need to download and include in your classpath. You can't include a C header file in Java.

Upvotes: 1

stefan bachert
stefan bachert

Reputation: 9616

You can't include C/C++ headers into java source code.

Maybe you want to define a native implementation for a java method.

http://java.sun.com/docs/books/jni/

Upvotes: 1

Related Questions