Jump to content

Prospeed help needed


 Share

Recommended Posts

Hi guys I decided to try prospeed API because with Autoi GDI+ api I didn't manage to have a fluid display a buffered image while moving around the edges of the screen (when the GUI is partly out of the screen it simply eats your CPU and can flicker at times)

(Also I can't write text very fast with GDI+ with stable performances : /)

But sadly using prospeed to ImportPNG then PaintPNG performances are even worse...

(much flickering!)

No examples on the prospeed UDF site handle draging the window, much less around the edges of the screen...

So I was wondering if you guys know a way to paint a background and stuff on it and refresh that when WM_PAINT messages are received without all those problems?

Edited by eleria
Link to comment
Share on other sites

$testhdc = GetHDC()
$import = ImportPNG(1,"background.png")

PaintPng(1, $testhdc, 0, 0, $import, 0)

And then

PaintPng(1, $testhdc, 0, 0, $import, 0)

At every WM_Paint event except the first since during the first $testdc has no value yet...

And when dragging the window when it isn 't completely inside the screen it flickers and it is jaggy

A portion of my script is still drawing using the GDI+ UDF since for the moment I can't assure fluid movement with only a background to be drawn :) (I want to draw many sprites depending on coordinates I extract from a database...)

Edited by eleria
Link to comment
Share on other sites

try it this way,

#include <prospeed30.au3>

Opt("GUIOnEventMode", 1)

GUICreate("", 800, 600)
GUISetOnEvent(-3, "_exit")
GUISetState()

$hdc = GetHDC()
CreateBuffer(800,600) ; create buffer for WM_PAINT

$pic = CreateImage(800,600) ; Create empry bitmap
$png = ImportPng(0,"animal.png") ; import png image
PaintPng(0,$pic,0,0,$png,0) ; paint png image to empty bitmap

PaintImage($hdc,0,0,800,600,$pic,0,0,0) ; paint bitmap to window

SetBuffer($pic) ; set screenbuffer with bitmap , can allso with hDC

While 1
    Sleep(1000)
WEnd

Func _exit()
    Exit
EndFunc
Link to comment
Share on other sites

Yes I most certainly do

EDIT : Ok DLL wasn't in the directory, but anyway moving window produces jagginess around the edges of the screen

Is Windows not meant to display window contents while moving at all? Or maybe only feasible with directx/draw?

Edited by eleria
Link to comment
Share on other sites

try to move a explorer window , if it has the same jagginess then your videodrivers are not

installed properly.

its strange because i dont have any problems overhere

Link to comment
Share on other sites

Only a very small flickering trail occur on any other program when moving inside/outside the desktop area.

Even some small blocks out of the window are drawn a bit late when moving at a normal speed with prospeed : /

EDIT : But hey I could live without it...

What I would like to know is if I need to draw sprites and text ontop, where would I put that part inside your example?

Edited by eleria
Link to comment
Share on other sites

Back to some questioning :)

Is it possible once I've loaded a sprite to alter it's color values?

It would spare me the need to create a variable number of sprites with different colours... (I can't know in advance how many different colour I need because It depends on data I fetch from sql)

Or I would still need to draw with the standard GDI+ UDF ... T_T

Edited by eleria
Link to comment
Share on other sites

You can change the sprite picture as much as you want

$spritePic = LoadFileImage("plane.jpg")
$fx = InitFX($spritePic)
ExchangeRgb($spritePic,0,0,$fx,50,0,0)

$sprite = sprite($spritePic, $hdc, 0, 0, 100, 100, 1, 1, 1, 50, 50)
Edited by jpam
Link to comment
Share on other sites

Well it seems that when I use your transformation on my sprites they take a weird rainbow colour (even if I copy exactly what you suggested)

And also window redrawing seems to take a while when my 200-800 sprites are loaded :)

I tried with both png and bmp

EDIT: after a few tries, it seems that when using ExchangeRgb it only works when I put the same numbers for R & G & B

Edited by eleria
Link to comment
Share on other sites

my 200-800 sprites are loaded

200 to 800 sprites :)

man , you need a fast computer to draw so many sprites on screen at ones !

can you send me your sprite bitmap, so i can test with it ?

Link to comment
Share on other sites

Sent the image to you.

But sprites fllickering almost the same when there is one and when there is 200 ^^"

I can make so that there is no flickering by doing Sprite to Background but the problem is that I want that when the user selects a certain option only some sprites get drawn...

Edited by eleria
Link to comment
Share on other sites

first problem is when you create a array from your bitmap

it must can be divided by 4, otherwise you get strange results

so i created a new one 8x8 and copied your sprite picture in it.

second problem is when you use a not animated sprite ,you have to set the $S_FRAMES and $S_START_FRAME to 1

when you create a sprite.

Sprite($S_Spriteplane, $S_Destination, $S_offsetX, $S_offsetY, $S_WIDTH, $S_HEIGHT, $S_FRAMES, $S_START_FRAME, $S_FRAME_SPEED, $S_posX, $S_posY)

example creates 400 sprites and changing colors

i attached the new sprite below.

#include <Prospeed30.au3>

Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}","_Exit")
GUICreate("Sprite FX", 600, 400)
GUISetOnEvent(-3, "_exit")
GUISetState()

$back = Background("autoit_builder_wall_800x600.jpg", 0, 0, 600, 400)

$load = LoadFileImage("msg-24989-1211826305.png")
$fx   = InitFx($load)

Dim $sprite[401]
For $i = 1 To 400
    $sprite[$i] = sprite($load, $HDC, 0, 0, 8, 8, 1, 1, 1, Random(0,600,1), Random(0,400,1)) 
Next

While 1
    ExchangeRgb($load,0,0,$fx,0,100,0)
    Sleep(500)
    ExchangeRgb($load,0,0,$fx,0,-100,0) 
    Sleep(500)
    ExchangeRgb($load,0,0,$fx,100,0,0)
    Sleep(500)
    ExchangeRgb($load,0,0,$fx,-100,0,0) 
    Sleep(500)
WEnd

Func _exit()
    FreeAllImages()
    deleteallsprites()
    Exit
EndFunc

post-5777-1211832357_thumb.png

Edited by jpam
Link to comment
Share on other sites

Slowly getting there I think but still...

But strangely sometimes sprites get drawn partly, some other times they appear as squares filled with one colour :)

See my attachment for a view of the scrambled display I get

This is my loop code :

dim $drawx[$total], $drawy[$total], $sprite[$total]
For $g = 0 TO ($total-1)
    $seedR = random(55,255,1)
    $seedG = random(55,255,1)
    $seedB = random(55,255,1)   
    
    $drawx[$g] = Floor(BitShift($xx[$g], 5))
    $drawy[$g] = Floor(($yy[$g]) / 45.5)

        ExchangeRgb($spritePic,0,0,$fx,$seedR,$seedG,$seedB)
    $sprite[$g] = sprite($spritePic, $hdc, 0, 0, 8, 8, 1, 1, 1, $drawx[$g], $drawy[$g]) 
    SpriteToHDC($sprite[$g])

    ExchangeRgb($spritePic,0,0,$fx,"-"&$seedR,"-"&$seedG,"-"&$seedB)

Next
DeleteAllSprites()

post-24989-1211847273_thumb.png

Edited by eleria
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...