Sign in to follow this  
Followers 0
Anonymous2342

2D Game Helper

1 post in this topic

#1 ·  Posted (edited)

I could't create a net thread in the "Example Scripts" forum

The error returned was:

Sorry, you do not have permission to start a topic in this forum

Introduction

I always wanted to create my own little game, this is my first game project for AutoIt.

My idea ist to create pictures and move them on the GUI. So now i created Functions which help to create little 2D games.

Basic

_SetPlayingField()

This function defice the rand of the playing field. All Objects can only created in this field an they notice, if they hit the rand. _SetPlayingField(0,0,500,500) set the point to (0|0) and the width and the height to 500

_CreateObject()

Create a picture on the field.

$testbild=_CreateObject("bild.jpg",100,450,50,50,"test",2) create an object with the image "bild.jpg" the coordinates are x=100 and y=450. At the moment we son't know what the word "test" means but it is not so important.

But the last parameter is important, 0 for example is an Object which can't touch other objects.

_ObjectTouch()

With this function xou can check if an object hit another object or the rand. if _ObjectTouch($testbild)=0 (touch nothing=0)

_ObjectMove()

The object is moved on the field: _MoveObject($testbild,"x",10)

The $testbild object is moved on the X-Axis 10 pixel to the right side, but only if it's possibel!

If there is another object on the distance, nothing will happen.

_DeleteObject()

With _DeleteObject($testbild) the objekt will be removed.

All Functions:

;==============================================Funktionen====================================

; _SetPlayingField()

; _CreateObject()

; _MoveObject()

; _ObjectTouch()

; _DeleteObject()

; _ObjectTouchClass()

; _GetObjectPosition()

; _TeleportObject()

; _ObjectSetPicture()

; _ObjectSetClass()

; _ObjectSetTyp()

; _ObjectTouchObject()

; _SetObjectSize()

; _SetObjectGroup()

; _MoveObjectGroup()

; _ObjectGroupTouch()

; _ObjectTouchObjectGroup()

; _ObjectGroupTouchClass()

; _GetObjectGroup()

; _DeleteObjectGroup()

; _GetObjectGroupString()

; _GetObjectGroupArray()

; _TeleportObjectGroup()

; _GetObjectGroupPosition()

; _ObjectGroupSetPicture()

; _ObjectGroupSetClass()

; _ObjectGroupSetTyp()

;==============================================Funktionen====================================

Example:

I created a little Jump&Run game. You can go left/right and jump with space.

(It's like Super Mario)

Screenshot:

http://www.autoit.de/index.php?page=Attachment&attachmentID=3934&h=0f0335a22170cc7702f98251773ffb8f6cb1d9cc&lol=.jpg

Download:

Here is the Download!

All the descriptions in the script are in german.

Later i must translate them, but at the moment i am unhappy because my code ist to slow.

The code runs every 35 milliseconds and sometime it takes more than 10 msecs to run.

I already replaced "if then else" with switch ot select, because "if then else" is slow.

Sorry for my bad english!

Edited by OgerLord

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0